Java record-30-packaging class
Wrapper Class is applicable to native data type packaging. 1. Java provides eight native data types. However, the object type needs to be used in many places during use, and the Native data type is not an object. In this case, you need to package the native data type into the object type for use. 2. Java provides packaging classes for all eight native data types. The packaging class object carries the specific native data type value. 3. We can operate native data types like using object-type operations. All packaging classes (8 types) are located under the java. lang package. 4. The eight packaging classes in Java are Byte, Short, Integer, Long, Float, Double, Character, and Boolean. They use the same method and can achieve two-way conversion between native data types and packaging types. Example: public static void main (String [] args) {int I = 3; Integer integer = new Integer (I); int ii = integer. intValue (); System. out. println (I = ii);} Class Integerjava. lang. objectjava. lang. numberjava. lang. integerAll Implemented Interfaces: Serializable, Comparable <Integer> public final class Integer extends Number implements Comparable <Integer> The Integer class wraps a value of the primitive type int in an object. an object of type Integer contains a single field whose type is int. in addition, this class provides several methods for converting an int to a String and a String to an int, as well as other constants and methods useful when dealing with an int. next article: http://www.bkjia.com/kf/201510/447459.html