Search This Blog

Tuesday, December 17, 2013

What is java program?

/*Simplest of the java program*/
//By Saurabh Prakash
class simple program
{
public static void main(String args[])
{
System.out.println(“you are learning ”);
}
}

Line1:-/* Simplest of the java program*/. The description written in /* and */ is called comment. The comments are for explaining the program. The comments are not executed by java.
Line2:-//By Saurabh Prakash
The description written after // is also a comment. There is no need to close the comment line by //.
Line3:- class simple program
This line declares a class which is an object oriented. Everything is placed inside the class. The word class is a keyword. Simple program is a name of which is called identifier which specifies the name of class to be defined. The program always start with opening braces ’{’.
Line4:- public static void main(String args[])
This line defines a method named main. A java program must include this main() method. String args[] declares a parameter named args which has an array of object of the class type String. We can also write it as String[]args. The above main method is followed by another opening brace.
Line5:-System.out.print(“you are learning”);
In the above program this is the only execution statement. The print method is a member of out object which is a static data member of system class. The string to be printed is kept in double quotes. The statement end with a semi colon. This statement will give the output you are learning.
Line6:-}, this is a closing braces to close the statement.
Line7:-}, every java program must end with a closing braces. 

No comments:

Post a Comment