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 2 of 2

Thread: Java main method

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Location
    Wahiawa, Hawaii
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java main method

    Herb Schildt in his books Java A Beginner's Guide and Java:The Complete Reference shows the main method as being
    public static void main (String args[]).
    At first I thought it must be a typo until I realized it was the same in both books. I tried it in the Command Prompt and javac ran it. I have always seen the main method printed as
    public static void main(Strings[] args)
    In Schildt's version the square braces comes after args, but, every where else it is always put after String. While Schildt's version runs fine in the Command Prompt, it comes back as an error in the various IDEs I've used (NetBeans, Eclipse). Why the difference? While I assume that the braces after String is the preferred method, since javac runs it and since Schildt keeps printing the other version I can't help but wonder what the difference between the two is. Anyone know?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,195
    Thanks
    49
    Thanked 2,172 Times in 2,145 Posts

    Default Re: Java main method

    Is is a carry over from his C++?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Doesnt have Main Method?
    By connorlm3 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 26th, 2013, 01:42 PM
  2. create a test class (main method) to start(run) the class in Java
    By curious725 in forum Java Theory & Questions
    Replies: 5
    Last Post: August 1st, 2012, 03:21 AM
  3. Replies: 3
    Last Post: October 31st, 2011, 12:42 AM
  4. 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
  5. Java main method args
    By mattxo in forum Java Theory & Questions
    Replies: 3
    Last Post: May 16th, 2011, 09:45 AM