아이템 28. 배열보다는 리스트를 사용하라. #59
Unanswered
Irisation23
asked this question in
3. 과제
Replies: 2 comments
-
정리해주신 내용 잘 읽었습니다. 타입 정보 소거(ensure)에서 소거로 번역한 단어 ensure 가 확신시키다, 보증하다의 의미로 보아 |
Beta Was this translation helpful? Give feedback.
0 replies
-
항상 배열과 리스트를 비교할때 메모리 할당 관점에서 비교를 많이 해봤던 것 같은데요. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
📝 구성 - 구성애 선생님 아님.
Table of contents generated with markdown-toc
0. 들어가기에 앞서 🧐
배열(Array)
과리스트(List)
의 메모리 할당 방법적인 차이의 접근 주제가 아니다.배열(Array)
과리스트(List)
공변성, 불공변성과 실체화와 타입 정보 소거에 포커스를 두고 있다.1. 배열(Array) ✨
배열(Array)
에 다른 타입의 데이터 삽입을 위한 그림이다.배열(Array)
은 다른 타입의 데이터가 삽입 되어도 눈치채지 못한다.1.1 배열의 공변성
1.2 배열의 실체화
런타임
에도 자신이 담기로 한 원소의 타입을 인지하고 확인한다.ArrayStoreException 클래스 보기
ArrayStoreException
예외를 발생시킨다.2. 리스트(List) ✨
2.1 리스트의 불공변성
List<Type1>
은List<Type2>
의 하위 타입도 아니고 상위 타입도 아니다.2.2 리스트의 타입 정보 소거
제네릭의 타입 정보 소거 간단 예제 보기
런타임
에는 소거(ensure) 된다.new List<E>[] // 제네릭 타입
,new List<String>[] // 매개변수화 타입
,new E[] // 타입 매개변수
2.3 제네릭 배열을 만들지 못하는 이유는? 🤔
ClassCastException
이 발생할 수 있다.3. 배열을 리스트로 사용 해 보자! ✨
생성자에서 컬렉션을 받는 Chooser 클래스를 예로 살펴보자.
version 1. - 제네릭 적용 전
version 2. - 제네릭 첫 적용
version 3. - 타입 안정성 확보!
4. 핵심 정리 📚
5. 회고 🧹
2023.01.15 (일)
Beta Was this translation helpful? Give feedback.
All reactions