Let’s get into Details…


1.    public class FirstProgram

2.   {

3.   public static void main(String[] args)

4.  {

 5.  System.out.println(“This is to try my first program”);

6.   }

7.  }

Line number 1:

public – means everyone can access this program.

class – means object-oriented style of programming, the program is encapsulated within the class and that’s java.

FirstProgram – means the name of the class, to identify which or what class you’re working on, basically the name of your java program.

Line number 2:

{ – symbol which means start or begin for the class. Easy right?

Line number 3:

public – means the method can be called or invoked anywhere.

static – means no object  is needed to call this method. I’ll explain more about this word on my next post.

void – means no value is being returned.

main – the name of the method or procedure which means the main method, it’s like the main body in the program. I’ll discuss more about methods and main later. Just take it as it is that this is the name of the method.

(String[] args) – the argument that is being passed to this method main is an array of String and the name is args. I’ll discuss more about arguments and parameters on my succeeding posts. Example of String argument that is being passed to the main is the command line statement for executing the program (ex. java FirstProgram).

Line number 4:

{ – means begin for the main method.

Line number 5:

System.out.println – a program statement which means, print something to standard output device which is the screen monitor.

(“This is to try my first program”) – parenthesis is the symbol to enclose the function values or parameters. In this case, you have a string value that you want to print on the screen, the string value that will be printed on the screen is enclosed with the double quotations. String means a list of characters.

; – semicolon is to terminate the statement. Every statement must end with the semicolon. Like a period symbol in the sentence. In   java program, semicolon symbol is used.

Line number 6:

} – meaning end symbol for main method.

Line number 7:

} – meaning end symbol for the class.

I hope the above explanations are clear. Just leave your comments and questions below.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s