First simple program in java

First simple program in java for beginners.


class FirstProgram
{
         public static void main(String args[])
         {
                  System.out.print("This is my first simple program in java.");
         }
}

How to compile the simple program of java.

  • Save the above program with name FirstProgram.java the program should save with the same name as the class name where the public static void main method is defined.
  • Then open the command prompt go to the directory where you saved the file on your pc.
  • Then write the command to compile the program as javac FirstProgram.java hit enter key.
  • Then write the command to run the program as java FirstProgram and hit enter to execute the command or program.
The output will be as follows :-



 Keep following these steps and have happy coding and programming with java. 

0 Comments:

Post a Comment