Java Tutorial
Java is a high-level programming language launched by Sun Microsystems in May 1995.
Java can run on multiple platforms, such as Windows, Mac OS, and various other UNIX-based systems.
This tutorial uses simple examples to help you better understand the Java programming language.
Most of the code in the mobile operating system Android is written in the Java programming language.
Java Online Tools
My First Java Program
Below we use a simple example to demonstrate Java programming. Create a fileHelloWorld.java (the file name must match the class name), the code is as follows:
Example
public static void main(String[] args) {
System.out.println("Hello World");
}
}
Run example »
Note:String args[]andString[] argsBoth can be executed, but it is recommended to useString[] args, this avoids ambiguity and misinterpretation.
Run the above example, the output is as follows:
$ javac HelloWorld.java $ java HelloWorld Hello World
Execution command parsing:
Above we used two commandsjavacandjava。
javacAfter it comes the file name of the Java file, for example HelloWorld.java. This command is used to compile Java source files into class bytecode files, such as:javac HelloWorld.java。
After running the javac command, if compilation succeeds without errors, a HelloWorld.class file will appear.
javaAfter it comes the class name in the Java file; for example, HelloWorld is the class name, e.g., java HelloWorld.
Note: Do not add .class after the java command.
Gif demonstration:
