java first program code example

Example 1: java hello world

public class Main {

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

Example 2: what is hello world java

public class HelloWorld { 
   public static void main(String []args) {
      /* println() function to write Hello, World! */
      System.out.println("Hello, World!");     
   }
}

Example 3: how to print hello world in java

public class Hello
{
  	public static void main(String[] args)
    {
      /*Tip System.out.println(); shortcut Type 'sysout'and press Tab */
      System.out.println("Hello world!");
    }
}

Example 4: java code to print hello world

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

Example 5: first java program

// Your Package Name
package com.company;

public class Main {

    public static void main(String[] args) {
        // write your code here
        String Hi = "Hello World";
        String congrats = "This is your first Java Program";
        System.out.println(Hi);

        boolean hi = true;

        if (hi == true) {
          	System.out.println(congrats);
        }
    }
}

Example 6: hello world java

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

Tags:

Java Example