Wednesday, January 13, 2016

Topic 3: Java main method

All Java applications begin execution by calling main( ).

 

public static void main(String args[]) {

  • The public keyword is an access specifier.

  • The keyword static allows main( ) to be called without having to instantiate a particular instance of the class. main( ) is called by the Java Virtual Machine before any objects are created. 

  • The keyword void simply tells the compiler that main( ) does not return a value.

  • main( ) is the method called when a Java application begins. Java compiler will compile classes that do not contain a main( ) method but cannot run these classes.

  • String args[ ], declares a parameter named args, which is an array of instances of the class String. args receives any command-line arguments passed during program execution.

  • println( ) displays the string which is passed to it.

  • System is a predefined class that provides access to the system, and out is the output stream that is connected to the console.


Click for NEXT article.


Please feel free to correct me by commenting your suggestions and feedback.


No comments:

Post a Comment