1. Packaging
Packaging class: java provides a packaging class for each basic data type
-
byte Byte char Character short Short int Integer float Float double Double boolean Boolean
Function: The packaging class and the corresponding basic data type all represent the corresponding value, but the packaging class can better reflect the object-oriented thinking, for example, including methods: max, min
Packing: Convert the basic data type to the corresponding packaging class
Unboxing: Convert the packaging class to the corresponding basic data type
The above process is divided into automatic and manual
//手动装箱 Integer i1 = new Integer(99); //手动拆箱 int i2 = i1.intValue(); //自动装箱 Integer i3 = 111; //自动拆箱 int i4 = i3;
Flyweight mode: only for integer types, in jvm, [-128,127] will be cached in an area in the heap.
String constant pool: The string created by direct assignment will enter a specific area constant pool in the jvm heap.
The difference between Flyweight and Constant Pool: Flyweight is cached in advance with JVM, while constant pool is cached when the string is created.
2. Math method
Commonly used method: PI abs (absolute value) pow (power operation)
BigInteger: a larger number than the long type
BigDecimal: Represents a decimal with higher precision than double
3、System/Runtime
System:arrayCopy currentTimeMills
Runtime: Enables the application to connect to the environment in which it runs.
4、 String/StringBuilder/StringBuffer
Master some commonly used String methods
StringBuilder: A variable character sequence. Concatenating strings is the most efficient
StringBuffer: A thread-safe variable character sequence. Concatenating strings is more efficient