Java Tutorial | My First JAVA program

Java is a high-level programming language introduced by Sun Microsystems in May 1995.

Java can run on multiple platforms, such as Windows, Mac OS, and many other UNIX versions of the system.

This tutorial will give you a better understanding of the JAVA programming language through simple examples.

My first JAVA program

Below we show Java programming through a simple example, create the file (file name must be consistent with the class name) , the code is as follows:


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

Note: Both String args[] and String[] args can be executed, but String[] args is recommended to avoid ambiguity and misinterpretation.

Run the above example and the output is as follows:

$ javac$ java HelloWorldHello World


Execute the command resolution:

Above we used two commands javac and java.

Following javac is the file name of the java file, such as This command is used to compile the java source file into a class bytecode file, such as: javac .

After running the javac command, a HelloWorld.class file will appear if there is no error in compiling successfully.

Java followed by the class name in the java file, for example, HelloWorld is the class name, such as: java HelloWorld.

Note : Do not add .class after the java command.