Garbage collection mechanism (garbage collection)
The Java virtual machine can be understood as a CPU that uses bytecode as machine instructions;
There are different virtual machines for different operating platforms;
The Java virtual machine mechanism shields the differences in the underlying operating platforms and achieves "compile once, run anywhere."
Memory space that is no longer used should be recycled - garbage collection;
In languages such as C/C++, the programmer is responsible for recycling useless memory;
The Java language eliminates the programmer's responsibility to reclaim unused memory space; it provides a system-level thread to track the allocation of storage space, and when the JVM is idle, check and release those Memory space that can be released.
Garbage collection runs automatically during the running of the Java program, and programmers cannot precisely control and intervene;
Java source files have "java" as the extension. The basic component of a source file is a class, such as the HelloWorld class in this example.
There can be at most one public class in a source file. There is no limit to the number of other classes. If the source file contains a public class, it must be named according to the class name. //The naming should be consistent with the naming of the public class
The execution entry point of the Java application is the main() method. It has a fixed writing format:
public static void main(String args[]){…}
The above is the detailed content of Introduction to Java in Java Study Notes. For more information, please follow other related articles on the PHP Chinese website!