Check out example codes for "hello world java". It will help you in understanding the concepts better.

Code Example 1

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

Code Example 2

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

Code Example 3

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

Code Example 4

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

Code Example 5

class Main {

    private String string = "Hello World!";

    public static void main(String[] args) {
        Main main = new Main();
        main.helloWorld();
    }

    public void helloWorld(){
        System.out.println(this.getHelloWorld());
    }

    public String getHelloWorld(){
        return this.string;
    }

}

Code Example 6

// This is just a line of code, but publilc class.... is needed!
        System.out.println("This will be printed");

Learn ReactJs, React Native from akashmittal.com