Java learning: Hello World program with java

Recently, I begin to use java in my work. I used to c++ for more than 10 years.

Programmer start every thing begin with Hello World

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

Java main function, must be in a public class

public static void main(String[] args) {}

Compile HelloWorld


Execute HelloWorld

java HelloWorld
remember, not java HelloWorld.class
otherwise, you will got below error
Error: Could not find or load main class HelloWorld.class

Subscribe to Post, Code and Quiet Time.

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.