> 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/auto-boxing-and-auto-unboxing.md).

# String to Number, String to Wrapper class

**String to Number**\
1\. Using Integer.intValue()\
2\. Using Integer.parseInt()\
3\. Using Integer.valueOf()

```java
int i = new Integer("100").intValue();
int i2 = Integer.parseInt("100");
Integer i3 = Integer.valueOf("100");
```

| String->Primitive                                                                                                                                                                                                                                                                                                                                         | String->Wrapper class                                                                                                                                                                                                                                                                                                                          |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p>byte b = <strong>Byte</strong>.parseByte("100");</p><p>short s = <strong>Short</strong>.parseShort("100");</p><p>int i = <strong>Integer</strong>.parseInt("100");</p><p>long l = <strong>Long</strong>.parseLong("100");</p><p>float f = <strong>Float</strong>.parseFloat("3.14");</p><p>double d = <strong>Double</strong>.parseDouble("3.14");</p> | <p>Byte b = <strong>Byte.valueOf</strong>("100");</p><p>Short s = <strong>Short.valueOf</strong>("100");</p><p>Integer i = <strong>Integer.valueOf</strong>("100");</p><p>Long l = <strong>Long.valueOf</strong>("100");</p><p>Float f = <strong>Float.valueOf(</strong>"3.14");</p><p>Double d = <strong>Double.valueOf</strong>("3.14");</p> |

n진법의 문자열을 숫자로

```java
int i4 = Integer.parseInt("100",2);//100(2)->4
int i5 = Integer.parseInt("100",8);//100(8)->64
int i6 = Integer.parseInt("100",16);//100(16)->256
int i7 = Integer.parseInt("FF",2);//FF(16)->255


//there is no "FF" in decimal.
//int i4 = Integer.parseInt("FF");error
```
