Friday, August 3, 2018

How to write a basic program in Java?

Let's learn basic java program in this article:

public class BasicJavaProgram {

   /* Basic java program.
    * Output will be 'Hello World'
    */

   public static void main(String []args) {
      System.out.println("Hello World");    }
}

Steps to Compile and Run a Java program:

C:\> javac BasicJavaProgram.java
C:\> java BasicJavaProgram
Hello World

We use double forward slash for single line comment and we use /* .. */ for multi-line comment. 

No comments:

Post a Comment