Sunday, December 9, 2012

Java HelloWorld program explained

Line1: Every java program starts with class keyword and followed by user defined class names

Line2:* public: The method can be accessed outside the class / package* static: You need not have an instance of the class to access the method* void: Your application need not return a value, as the JVM launcher would return the value when it exits* main(): This is the entry point for the application

Line 3: curly braces opens here or just immediately after method name

Line4 : Printing the String constant into the console

Line5 : close the bracket for method

Line 6 : close the bracket for class Java Demo

In order to run this program you have to compile this program into byte code by the command ->javac JavaDemo.javaAnd Run the program by typing the below command-> java JavaDemoYou can see the following outputHelloWorld!