Wrapper class (Wrapperclass), for packages of native data types.
1. Java provides 8 types of native data. However, in many places where the object type is required for use, and the native data type is not an object, the native data type needs to be wrapped as an object type for use.
2. Java provides wrapper classes for 8 native data types. A wrapper class object that hosts the value of the specific native data type.
3. We can manipulate the native data type as if it were an object-type operation. All packaging classes ( 8 java.lang pack.
4. the eight wrapper classes in Java are:Byte, short,Integer,Long ,Float,Double,Character , Boolean. They are all used the same way, enabling bidirectional conversions of native data types and wrapper types.
Usage examples:
Public static void main (string[] args) {
int i = 3;
Integer integer = New Integer (i);
int II = Integer.intvalue ();
System. out . println (i = = II);
}
C Lass Integer
Java.lang.Object
Java.lang.Number
Java.lang.Integer
All implemented Interfaces:
Serializable, comparable<Integer>
Public final Class Integer extends Number Implementscomparable<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, the This class provides several methods for converting an int to a string and a string to an int., as well as othe R constants and methods useful when dealing with an int.
Java Record -30-wrapper class