3--Notepad development HelloWorld

Development steps:

  1. Create a notepad file, named Hello.java
    Note: You need to modify the suffix of Hello.txt to Hello.java
  2. Enter the following code in Hello.java:
public class Hello{
    
    
	public static void main(String[] args){
    
    
		System.out.println("Hello World!!");
	}
}
  1. Command line (cmd) input So
    Insert picture description here
    far, a simple HelloWorld applet is complete. Isn't it simple?
    There are two commands here: javac and java.
    Speaking of these two commands, I have to mention the two files Hello.java and Hello.class that appear above. The Hello.java file is the source file we wrote. This file cannot run. Hello.class is a file generated by javac command, it is a bytecode file, this file can be executed. So javac is naturally a compilation command, and the java command, as the name implies, is to execute the Hello.class command

Summarize and pay attention to the problem

  • The process of java program writing→compiling→running.
    Writing: The written java code is saved in the source file with "*.java".
    Compile: Use the javac command to compile the java source file we have written. Format: javac source file name. java
    run: use java command to interpret and run the byte name file. Format: java class name
  • Note: Multiple classes can be declared in a java source file. However, at most one class can be declared as public. And it is required that the class name of the class declared as public must be the same as the source file name.
  • The entry point of the program is the main() method. The format is fixed.

```java
public static void main(String[] args){
    
    }

 - [ ] 

 

 

Guess you like

Origin blog.csdn.net/qwy715229258163/article/details/113666297