API: (Appilcation programming Interface)
Is something that has been written, can be used directly to use the function, in Java in the form of a class encapsulation;
The role of the package: classify all class libraries as if a school is divided into different colleges,
Commonly used packages:
Java.lang: base class, such as String, Multi-threading, import not required
Java.util: Common tool classes, such as collection random generator, calendar, clock
java.io: File operation, input/output operation
java.net: Network operation
Java.math: Operations related to mathematical operations
Java.security: Security-related operations
java.sql: Database access
Java.text: Processing text, date numbers, information formats
Documentation notes:
/** Document Comments */
Added at the beginning of the class and method, to describe the author, time, version, to implement a detailed description of the function and other information
Convert annotations to HTML document descriptions through Javadoc;
String:
- Java.lang.String uses the final decoration and cannot be inherited;
- The string bottom encapsulates the character array and the operation algorithm for the character array;
- Once a string is created, the object is never changed, but the string reference can be re-assigned;
For example, string str = "Hello World": There is Hello World memory in the heap, and the STR variable holds the address in the stack.
If str = str+ "! "How did you add a" Hello world "to the heap? The new object, which is re-directed by Str, and the original "Hello World" will be recycled.
- Java strings are Unicode encoded in memory, with any one character corresponding to a two-byte fixed length encoding
string constant pool:
- For recurring string literals, the JVM will first look in the constant pool and return the object if it exists
- string is not conducive to frequent modification;
1 /**2 * used to test string3 * @authorAdministrator4 */5 Public classdemo01 {6 Public Static voidMain (string[] args) {7String str = "HelloWorld";8String str1 = "HelloWorld";//The object of the STR is reused9System.out.println (STR==STR1);//trueTen /* One * Compiler small features: A * If both sides of an operation are literal, then - * Calculations are calculated during compilation, and results are generated at the location of the expression - * Can save the overhead of Operation the */ -String str2 = "Hello" + "World"; - //String str2= Look in the "Hello World" bytecode file, the compilation process itself transforms the -System.out.println (STR==STR1);//true + -String STR3 =NewString ("Hello World"); +System.out.println (STR==STR3);//flase Create a new object because it uses new A } at}
About APIs, commenting documents, and string