Set<E>
의 메소드 선언을 보자.컴파일시 일반 유형 검사
public boolean add(E e);
public E get(int index);
그리고 이것을 사용해 보겠습니다.
List<Boolean> list = new ArrayList<Boolean>();
Integer i = list.get(0); //Predictably, here we get a compile error.
list.contains(new Integer(3)); //But this line is allowed. Why?
이 코드의 비상용 (내가 아는 바대로 간단하게 변환 됨)에서도 두 줄 모두에서 컴파일 오류가 발생합니다.
List s = new ArrayList();
s.contains((Boolean)(new Integer(3)));
Integer i = (Boolean)s.get(3);
그럼 일반적인 경우에 오류가 발생하지 않습니까?