Home Java Master-java Undrer Standing the HelloWorld Program

Related Tutorials


 
 

Share on Google+Share on Google+

Undrer Standing the HelloWorld Program

Advertisement
Class is the building block in Java, each and every methods & variable exists within the class or object.

Under Standing the HelloWorld Program

     

Class Declaration:

Class is the building block in Java, each and every methods & variable exists within the class or object. (instance of program is called object ). The public word specifies the accessibility of the class. The visibility of the class or function can be public, private, etc. The following code declares a new class "HelloWorld" with the public accessibility:

public class HelloWorld { 

 

The main Method: 

The main method is the entry point in the Java program and java program can't run without main method. JVM calls the main method of the class. This method is always first thing that is executed in a java program. Here is the main method:

public static void main(String[] args) {

......
.....

}

{ and is used to start the beginning of main block and } ends the main block. Every thing in the main block is executed by the JVM.

The code:

System.out.println("Hello, World");

prints the "Hello World" on the console. The above line calls the println method of System.out class.

The keyword static:

The keyword static indicates that the method is a class method, which can be called without the requirement to instantiate an object of the class. This is used by the Java interpreter to launch the program by invoking the main method of the class identified in the command to start the program.

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: June 12, 2007

Related Tutorials

Discuss: Undrer Standing the HelloWorld Program   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:3
anjit
October 11, 2011
where is stored static variable

where is stored static variable and method in java.?
lucky
March 26, 2012
java

Is static keyword mandatory in main() method?? if so, can u give me the detailed explanation??
srinu
April 15, 2013
knowledge improve

This is very useful and easy to learn.
DMCA.com