In order to prepare for the software competition two weeks later, let go of what you like, and let's take a good look at j2se!
1. Java Overview
The Java language is interpreted and executed, and the Java source code is compiled to generate a special. class intermediate character decoding file, and then the JVM is interpreted and executed.
The Java language encapsulates pointers in the upper layer. It ensures that this pointer (reference) can be used to access valid memory units.
The Java language does not allow many inheritance, so that the inheritance relationship can be a tree Assembly graph. Each class can only be composed of one parent class.
Java language development efficiency is high, but execution efficiency is low. (In fact, it's not much lower ...)
Java's garbage collection mechanism. In Java, the new object does not need to be deleted like C ++, And the JVM will recycle the garbage object based on the situation. (Lazy mechanism, wait until resources are available.) We can only recommend JVM garbage collection, for example (system. GC () runtime. GC () these two methods are recommended for JVM garbage collection)
JDK, Java Development Kit (class libraries and running commands), JRE, Java Runtime Environment, JVM, and Java Virtual Machine (explanation of the core of execution, the bytecode is translated into the machine code of the runtime environment, it can shield platform differences. JVM is not cross-platform .)
Java_home: Specifies the JDK installation path, classpath, path, and executable file location.
The file name of the Java source file must be the same as the class name of the public class defined in the file (the case page must be the same.
Definition of the main method in Java source code. The main method is the entry of the program.
Public static void main (string [] ARGs ){
System. Out. println ("Hello World ");
}
Java source files must also be compiled first, and compiled using javac XXX. Java commands. Java XXX is used for running.
Define the package structure to be placed in the first line of valid code, package XXX. XXX: the package definition can only be defined by one program. After the package definition is added, the javac-D path XXXX can be used for compilation. java, the-D command line parameter can specify the location of the Package Structure ". "indicates the current directory. Use the full name of the class during running.
Java XXX. XXX. XXXX is separated by the package names by dots. During running, you must run the program in the upper directory of the package structure.
Java annotations
Single line comment //......
Multi-line comment /*.......*/
Document comments/** ...... <p> (line feed label) */. You can use the javadoc command to generate a comment document (in HTML format) based on the document comments in the original code ). HTML tags can be used in document annotations.
Javadoc-D path (specify the Save path of the annotation document)
Document comments are generally written before class definitions, before methods, and before attributes.
In the document annotations, @ Author can be used to represent the author of the program, and @ version represents the version of the program. The first two annotations must be written before the class definition, for method annotation @ Param to comment on the parameter, @ return to comment on the return value @ throws to comment on the thrown exception.
The jar command is used to create a XXX. jar file.
Usage: jar {ctxu} [vfm0mi] [Jar-file] [manifest-file] [-C Directory] File Name...
Option:
-C. Create a new archive
-T list the archived content
-X expand the named (or all) files in the archive
-U: update an existing archive
-V generates detailed output to the standard output
-F specifies the archive file name
-M contains the marker information from the specified file.
-0 storage only; zip compression format not used
-M does not generate a manifest file for all items
-I generates index information for the specified JAR File
-C changes to the specified directory and contains the following files:
If a file name is a directory, it is recursively processed.
The configuration (manifest) file name and archive file name must be specified, in the same order specified by the 'M' and 'F' signs
Example 1: Archive two class files to an archive file named 'classes. jar:
Jar CVF classes. Jar Foo. Class bar. Class
Example 2: use an existing manifest file 'mymanifest'
Archive the file to an archive file named 'classes. jar:
Jar cvfm classes. Jar mymanifest-C Foo /.
Generally, the jar CVF file name is used. JAR file path (xxx/XXX/xxx. class) You can also compress a directory. As long as the specified path is a folder, the command line parameters of the jar command can start with "-" or not.
To run a Java program, first start the Java virtual machine, and then find it. class file, first from the system class library (the system will find it under the directory, so the complete class name is required ), if you cannot find it, you will find it in the directory set by classpath. Then load it to the Java Virtual Machine.
The system will implicitly import the java. lang Package, the import package name, and the class file in the import package in each Java program.
Java. lang package, which is a basic package.
Java. util package, which is a tool package.
Java. Io package, which is used for input/output operations
Java.net package, which is used for network programming.
Java. AWT, java. Swing, javax. Swing, java. Event, and other packages are used for graphics programming.
Applaction Java applications, Java applications must have a main () method.