First Program in Java

// WAP in Java that prints Hello World.

public class HelloWorld{
          public static void main(String[ ] args){
                    System.out.print("Hello, World !!!!!!");
          }
}

In above ( // ) sign represent a comment in a program. What ever we write after ( // ) symbol, it is ignored while the process is compiled. Symbol ( // ) is use to comment a single line and ( /*..........*/ ) and this symbol is used to comment a multiple lines in program. Writing a comment in the program is good habit of a programmer. It helps other programmer to read and understand the program.

// WAP in Java that prints Hello World. 

Note:- this line will be ignored by the compiler while compiling the process.
--------------------------------------------------------------------------------------------------------------------------

// WAP in Java that prints Hello World.

public class HelloWorld{
          public static void main(String[ ] args){
                    System.out.print("Hello, World !!!!!!");
          }
}

--------------------------------------------------------------------------------------------------------------------------

Above, Bold word is a class name. We know that class is blueprint for object creation. Every java program must have at least one class. And class is started with public keyword.

--------------------------------------------------------------------------------------------------------------------------

// WAP in Java that prints Hello World.

public class HelloWorld
{
          public static void main(String[ ] args){
                    System.out.print("Hello, World !!!!!!");
          }
}

--------------------------------------------------------------------------------------------------------------------------

Above we can see that after the declaration of class { symbol is used. It is called open brace and at the end it must be closed with close brace }. All the codes are written in between these braces.

--------------------------------------------------------------------------------------------------------------------------

// WAP in Java that prints Hello World.

public class HelloWorld
{
          public static void main(String[ ] args){
                    System.out.print("Hello, World !!!!!!");
          }
}

--------------------------------------------------------------------------------------------------------------------------

Above highlighted statement is starting point of java application. Here, main method must be called. In this statement static is used, it means main method is usable in any context of class. No any object is required to execute the main method. Void is used here because it does not return any any data. Only the given task is performed or executed. (String[ ] args) is a parameter to the main method.

--------------------------------------------------------------------------------------------------------------------------

// WAP in Java that prints Hello World.

public class HelloWorld
{
          public static void main(String[ ] args)
         {
                    System.out.print("Hello, World !!!!!!");
          }
}

--------------------------------------------------------------------------------------------------------------------------

After the main method, open brace and close brace is used. What ever we write in between them it is called the body of the main method.

--------------------------------------------------------------------------------------------------------------------------

// WAP in Java that prints Hello World.

public class HelloWorld
{
          public static void main(String[ ] args)
         {
                    System.out.print("Hello, World !!!!!!");
          }
}

--------------------------------------------------------------------------------------------------------------------------

Above command give the command to print the characters which is closed with inverted comma. (System.out) is a standard output object in java programming language.



Comments

Popular posts from this blog

Logical operator in JAVA

Class and Object in Java

Loop Structure