// EXPLANATION OF PUBLIC STATIC VOID MAIN(STRING[ ] AR)
PUBLIC: The main method should be declared as public, so that the JVM can access the main method from any location.
STATIC: The main method should be declared as static, so that the JVM cam invoke the main method directly by using class name.
VOID: The caller of the main method is JVM and the JVM does not expect any value from the main method, therefore the main method should not return any value to JVM hence we specify the return type as void.
MAIN( ): main is the name of the method, a valid java identifier, following the java coding conventions and the name is fixed.
STRING[ ]: It is used for storing command line arguments.
The name of the string array can be any valid java identifier.
RULE: If a declaration contains multiple modifiers, then we can specify them in any sequence.
static public void main(String[ ] abc)
public static void main(String[ ] abc)
//EXPLAIN SYSTEM.OUT.PRINTLN( ):
Out is a reference variable declared as static in System class and therefore it can be accessed directly by using class name(System.out).
System.out will provide an object of PrintStream class. using which we can access the methods of PrintStream class and therefore we write System.out.println().
PUBLIC: The main method should be declared as public, so that the JVM can access the main method from any location.
STATIC: The main method should be declared as static, so that the JVM cam invoke the main method directly by using class name.
VOID: The caller of the main method is JVM and the JVM does not expect any value from the main method, therefore the main method should not return any value to JVM hence we specify the return type as void.
MAIN( ): main is the name of the method, a valid java identifier, following the java coding conventions and the name is fixed.
STRING[ ]: It is used for storing command line arguments.
The name of the string array can be any valid java identifier.
RULE: If a declaration contains multiple modifiers, then we can specify them in any sequence.
static public void main(String[ ] abc)
public static void main(String[ ] abc)
//EXPLAIN SYSTEM.OUT.PRINTLN( ):
- System is a predefined class available in java.lang package.
- Out is a reference variable of PrintStream class declared as static in System class.
- println() is predefined method available in PrintStream. PrintStream is a predefined class available in java.io package.
Out is a reference variable declared as static in System class and therefore it can be accessed directly by using class name(System.out).
System.out will provide an object of PrintStream class. using which we can access the methods of PrintStream class and therefore we write System.out.println().
No comments:
Post a Comment