ArrayList<Integer> arrI = new ArrayList<Integer>();
ArrayList arrO = arrI; // Warning
/* It is ok to add a String as it is an ArrayList of Objects
but the JVM will know the real type, arrO is an arrayList of
Integer...
*/
arrO.add("Hello");
/* How I can get a String in an ArrayList<Integer> ??
Even if the compiler told me that I will get an Integer!
*/
System.out.println(arrI.get(0));
아무도 여기서 무슨 일이 일어 났는지 설명 할 수 있습니까?Generics Type 문제
경고를 읽고 이해 했습니까? 경고는이 코드를 작성함으로써 arrI에 대한 모든 컴파일 시간 유형 검사를 건너 뜁니다. – DJClayworth
@DJClayworth ok,하지만 마지막 줄은 정말 이상합니다. – JohnJohnGa