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 |
Tags
- DATAPATH
- DoM
- CSS
- XML
- for
- function
- Class
- architecture
- computer
- web
- html
- MIPS
- DS
- DB
- MacOS
- while
- python
- Pipelining
- javascript
- Linux
- Java
- system
- Algorithm
- data structure
- react
- control
- instruction
- php
- github
- mysql
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 |