Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Linux
- function
- Algorithm
- Java
- MacOS
- react
- DoM
- instruction
- system
- php
- computer
- MIPS
- python
- CSS
- Pipelining
- web
- architecture
- github
- DB
- while
- Class
- DS
- control
- DATAPATH
- XML
- mysql
- html
- javascript
- data structure
- for
Archives
- Today
- Total
YYYEJI
[JAVA] Wrapper class란? 본문
728x90
Wrapper class란?
Primitive type을 class type으로 포장해 주는 클래스를 말합니다.
Primitive type | Class type | Method to convert back |
int | Integer | intValue() |
long | Long | longValue() |
float | Float | floatValue() |
double | Double | doubleValue() |
char | Charactcer | charValue() |
Integer class로 예제를 살펴보겠습니다.
public static void main(String[] args) {
Integer n = new Integer(10);
System.out.println(n.intValue());
}
Primitive type의 변수에 값을 할당할 때는 간단하게 "="(assignment) 연산자를 사용하면 되지만,
class로 wrapper된 Integer class는 메소드(method)를 통해 값을 할당할 수 있습니다.
◡̈
'Java' 카테고리의 다른 글
[JAVA] 패키지(Package)란? (0) | 2022.12.27 |
---|---|
[JAVA] 오버로딩(Overloading)이란? (0) | 2022.12.27 |
[JAVA] Static Method와 Static Variable (0) | 2022.12.27 |
[JAVA] Constructor란? (0) | 2022.12.27 |
[JAVA] Class Type인 변수 할당하기 (0) | 2022.12.26 |