> For the complete documentation index, see [llms.txt](https://heunnajo.gitbook.io/java/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://heunnajo.gitbook.io/java/java.lang-package-and-useful-class/wrapper-class.md).

# Wrapper class

\- The class wraps primitive type.\
\- When handle 8 types of primitive type as object. =>why? OOP is Object-Oriented Programming. It needs to be as Object. 90% is Object and remains are primitive type because of performance.

```java
public final class Integer extends Number implements Comparable {
    ...
    private int value;//wraps int type.
}
```

| primitive type | wrapper class | constructor                                                               | example                                                                                        |
| -------------- | ------------- | ------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| boolean        | Boolean       | <p>Boolean(boolean value)</p><p>Boolean(String s)</p>                     | <p>Boolean b = new Boolean(true);</p><p>Boolean b2 = new Boolean("true");</p>                  |
| char           | **Character** | Character(char value)                                                     | Character c = new Character('a');                                                              |
| byte           | Byte          | <p>Byte(byte value)</p><p>Byte(String s)</p>                              | <p>Byte b = new Byte(10);</p><p>Byte b2 = newByte("10");</p>                                   |
| short          | Short         | <p>Short(short value)</p><p>Short(String s)</p>                           | <p>Short s = new Short(10);</p><p>Short s2 = new Short("10");</p>                              |
| int            | **Integer**   | <p>Integer(int value)</p><p>Integer(String s)</p>                         | <p>Integer i = new Integer(100);</p><p>Integer i2 = new Integer("100");</p>                    |
| long           | Long          | <p>Long(long value)</p><p>Long(String s)</p>                              | <p>Long l = new Long(100);</p><p>Long l2 = new Long("100");</p>                                |
| float          | Float         | <p>Float(double value)</p><p>Float(float value)</p><p>Float(String s)</p> | <p>Float f = new Float(1.0);<br>Float f = new Float(1.0f);<br>Float f = new Float("1.0f");</p> |
| double         | Double        | <p>Double(double value)</p><p>Double(String s)</p>                        | <p>Double d = new Double(1.0);</p><p>Double d = new Double("1.0");</p>                         |

```java
Integer i = new Integer(100);//address : 0x100
Integer i2 = new Integer(100);//address : 0x200

System.out.prinln("i==i2?" + (i==i2));//false.0x100!=0x200
System.out.prinln("i.equals(i2)?" + i.equals(i2));//true.means overriding.
//오른쪽 값이 더 작으면 양수,오른쪽 값이 더 크면 음수, 같으면 0
System.out.prinln("i.compareTo(i2) ="+i.compareTo(i2)); 
System.out.prinln("i.toString()="+i.toString());


```
