After we have installed and configured Java, we have to do a great job, according to international practice, the first program must be Hello World, let's look at Hello World.
1.Hello World Run
Hello World Process:
- Write Java code to a file in the. java suffix to save.
- The. java file is compiled with the Javac Compile command (generates a. class file after compilation).
- Run the generated, class file from the Java command.
Flow chart:
F:\Demo.java File Contents:
Public class demo{ publicstaticvoid main (string[] args) { System.out.println ("Hello world!" ); }}
Go to the command-line window and execute Javac and Java commands, such as:
As you can see, the result is: Hello world! is printed at the command line.
2.Hello world should pay attention to the issues and details
- The main function, the main function, is the entry of the program and is called by the virtual machine to guarantee the independent operation of a class. The main function can only have one. The format must be public static void main (string[] args) {//code }
- Class is the Java keyword used to define classes. It should be noted that if the class is decorated with the public keyword, the saved. Java file name must be the class name. java.
[Java Learning notes] Hello world, those things.