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 HelloWorld.java (file name must be consistent with the class name) , the code is as follows:
Examples
public 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 HelloWorld.java $ java HelloWorld Hello 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 HelloWorld.java. This command is used to compile the java source file into a class bytecode file, such as: javac HelloWorld.java .
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.
Comments
Post a Comment