Overview of the Java language and environment configuration

1.1 Java History

Understand the birth and development of Java

1. 2 Java program running mechanism

1.2.1 operating mechanism of high-level language

  • Compiled language
  • Interpreted language

Operational procedures and mechanisms 1.2.2 Java JVM

After compiling the generated Java platform-independent bytecode files (.class file), and then the responsibility of the Java Virtual Machine interpreted bytecode files

1.3 to develop Java-ready

1.4 The first Java program

Run the first file HelloWorld.java

1. Create a new text file

2. Write code

public class HelloWorld{
    public static void main(String[] args){
        System.out.println("Hello World!");
    }
}
复制代码

3. Modify the text file named HelloWorld.java

4. get class file in cmd javac HelloWorld.java

javac HelloWorld.java
复制代码

5. cmd Run the file name (do not need to bring class suffix)

java HelloWorld
复制代码

A small problem, your computer may be set to hide file extensions, you need to modify the tool inside

class bytecode files, is an intermediate code file, can not be run directly, need to be translated the JVM (Virtual Machine)

The basic rule 1.5 Java programs

Organization 1.5.1 Java program

  • Java program must exist as a class

  • A class must contain a main method and only

    public static void main(String[] args)
    复制代码

Naming 1.5.2Java source code

  • Extension must be .java
  • public class name as the primary filename of the Java source code and the source file definition.

1.6 interactive tool: jshell

//cmd内输入jshell

/help 获取帮助信息
/exit退出Jshell
复制代码

1.7 garbage collection

1.8 When to use IDE tool

Advice: not recommended for beginners to use IDE

Guess you like

Origin juejin.im/post/5e772125e51d4526db752933