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: New to java.. what does this mean?

  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up New to java.. what does this mean?

    Hello, I am new to Java. I got in to it a couple months ago and I've been looking for tutorials but only help me with basic stuff and I keep learning the same things over and over again. I would be able to make some simple programs from what I remember but none of it makes sense to me and why it's there.. such as this 'Hello world' program :
    ********************************************
    public class MyFirstJavaProgram{

    /* This is my first java program.
    * This will print 'Hello World' as the output
    */

    public static void main(String []args){
    System.out.println("Hello World"); // prints Hello World
    }
    }
    *********************************************

    I would know how to make that simple program but I don't know what it means that I'm typing. Such as, what's the point of the brackets at the beginning and end? What does **public static void main(String []args)** do? Those are the only things in that programming that doesn't make any sense to me.. Please somebody explain. Thanks very much

    (by the way, I'm 13. Not expecting complicated stuff anytime soon. Looking for a bright future from programming)


  2. #2
    Member
    Join Date
    Apr 2012
    Posts
    160
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Default Re: New to java.. what does this mean?

    The brackets represent a code body. An opening bracket must have a closing bracket of course. So the first set would be the "body" of the class MyFirstJavaProgram. The second being the body of the main method.

    The public modifier is used so that other classes accessing this class would be able to use this particular method. If you desire to learn more about this, do a search on Inheritance.

    Now the static modifier (I seem to always even confuse myself on this one so correct me if I'm wrong) essentially tells the program that there is only one instance of whatever it is modifying. This is why you can't have non-static variables in a static body.

    The void is the return type. This can be anything, but for this particular method, it returns void; meaning it doesn't return anything.

    The following bit is the method's name and parameters. Any program which you want to run must have a main method, which takes an array of Strings as the argument.

    Hopefully this helps. I'll be glad to try and clarify any of this if possible.

Tags for this Thread