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

javac HelloWorld.java

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

Comments

Popular posts from this blog

react-native run-android : sun.security.provider.cert path.SunCertPathBuilderException : unable to find valid certification path to req uested target

react-native run-android : do not build/update modified code(App.js)

How to fix error : no module named sendgrid when try to use sendgrid python lib in PHP.