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
- es6
- entity
- 컴포넌튼
- 서버리스 #
- 당근마켓
- ES5
- 0.5px border
- Websocket
- 0.25px border
- &연산
- jwt
- angular
- npm
- 1px border
- 문서번호
- Strict
- TypeScript
- ZOOM
- 데이터베이스 #try #이중
- github
- 10px
- font-size
- 타입스크립트
- TS
- 으
- 0.75px border
- 클론코딩
- Props
- 전역변수
- literal
Archives
- Today
- Total
복잡한뇌구조마냥
[JAVA] java.lang + 오토박싱 본문
오토박싱
- 기본 타입 데이터를 객체 타입의 데이터로 자동 형변환 시켜주는 기능
자바는 기본적으로 다양한 패키지를 지원 그중에서 가장 중요한 패키지
- java.lang 패키지의 클래스는 import 하지 않고도 사용할 수 있음.
- java.lang 패키지에는 기본형 타입을 객체로 변환 시킬 때 사용하는 Wrapper 클래스가 있음.
- Boolean, Byte, Short, Integer, Long, Float, Double 클래스
- 모든 클래스의 채상위 클래스인 Object도 java.lang
- 문자열과 관련된 String, StringBuffer, StringBuilder도 모두 java.lang
- 화면의 값을 출력할 때 사용하는 System 클래스도 java.lang
- 수학과 관련된 Math 클래스도 java.lang
- Thread와 관련된 중요 클래스들이 java.lang
- 이 외에도 다양한 클래스와 인터페이스가 java.lang 패키지에 속해있음.
public class WrapperExam {
public static void main(String[] args) {
int i = 5;
Integer i2 = new Integer(5);
Integer i3 = 5; //오토박싱
int i4 = i2.intValue();
int i5 = i2; //오토언박싱
}
}
오토박싱 ( Auto Boxing )
- 기본형 int인 값은 자동으로 Integer 형태로 변환됨
오토 언박싱 (Auto unboxing)
- Integer 객체 타입의 값을 기본형 int로 자동으로 변환되어 값을 할당
- 오토박싱과 오토 언박싱은 JAVA 5부터 지원
- 내부적으로 java.lang 패키지의 Wrapper 클래스가 사용되고 있음.
참고자료:
https://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html
Integer (Java Platform SE 7 )
Returns the value obtained by rotating the two's complement binary representation of the specified int value left by the specified number of bits. (Bits shifted out of the left hand, or high-order, side reenter on the right, or low-order.) Note that left r
docs.oracle.com
LIST
'BE > JAVA' 카테고리의 다른 글
[JAVA] 날짜와 시간 ( Date, Calendar, java.time ) (2) | 2025.06.14 |
---|---|
[JAVA] 컬렉션 프레임워크 ( 자료구조, Set, List, Map ) (1) | 2025.06.10 |
[JAVA] 예외 처리 ( Exception, Throws, 커스텀 Exception ) (1) | 2025.06.07 |
[JAVA] 내부클래스 (0) | 2025.06.07 |
[JAVA] 오버라이딩, 클래스 형변환 (1) | 2025.06.06 |