Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: main method

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    23
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default main method

    One interviewer has asked me one question that why main() method has argument "String[] arg".What is reason behind this ??
    I am unable to explain it because i never think about it ......Please guys help me


  2. #2

  3. #3

    Default Re: main method

    String args[], which is actually an array of java.lang.String type, and it's name is args here. It's not necessary to name it args always, you can name it strArray or whatever you like, but most programmer prefer to name it args, because that's what everyone else do. When we run a Java program from command prompt, we can pass some input to our Java program. Those inputs are stored in this String args array. For example if we modify our program to print content of String args[] .

  4. #4
    Junior Member
    Join Date
    Sep 2017
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: main method

    Furthermore, args[] or "arguments" can be used as parameters instructing how a program should run.

Similar Threads

  1. Replies: 1
    Last Post: May 27th, 2014, 07:39 PM
  2. Replies: 2
    Last Post: May 27th, 2014, 12:36 PM
  3. Replies: 3
    Last Post: October 31st, 2011, 12:42 AM
  4. How to call a value from a different method to main
    By CrimsonFlash in forum What's Wrong With My Code?
    Replies: 13
    Last Post: October 22nd, 2011, 06:29 PM
  5. How do I call a method from the main method?
    By JavaStudent1988 in forum Java Theory & Questions
    Replies: 5
    Last Post: October 19th, 2011, 08:37 PM