Thursday, July 23, 2009

This HelloWorld program to java world

We can step into the world of java by this simple program
  1. class JavaDemo{
  2. public static void main(String Args[])
  3. {
  4. System.out.println("HelloWorld!");
  5. }
  6. }
  • 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 JavaDemo
In order to run this program you have to compile this program into bytecode by the command ->javac JavaDemo.java
And Run the program by typing the below command
-> java JavaDemo
You can see the following output
HelloWorld!



follow me on twitter::http://twitter.com/shamsudeen

No comments:

Post a Comment