Pages

Monday, August 18, 2014

First program in java

Java first program and explanation


public class Hello

  • class is a keyword, which is identifier used to declare a new class (Hello is a new class).

public static void main(String[] args)

  • This is main method of the class.
  • It is suggests that program will begin executing.
  • All of the java program begin their execution by calling main().
  • Public keyword is an access specifier which allows to control the visibility of a java program.
  • Here the main () must be declared public.
  • static allows main () to be called without declaring the objects.
  • There is only one parameter in main () i.e. String args[], basically it is an array of instances of the string class.
System.out.println("Hello World!)
  • Hello World! - this line used to display the string.
  • The println() is a method which is used to take the cursor on to a new line.

No comments:

Post a Comment