Hello World in Java

Write a Java program that prints a greeting. Save it as HelloWorld.java and run it from a terminal.

A simple example

Print a greeting

  1. Start with "Hello"
  2. Do this Print the text
  3. Result Hello
Quotation marks enclose the text in the program. Only the letters appear in the output.
Main.java
class Main {
    public static void main(String[] args) throws Exception {
        System.out.println("Hello");
    }
}
Output
Hello