제네릭에서 유형 삭제의 개념을 읽었습니다. 아래 코드를 실행하는 동안 나는 혼란스러워했다. 유형의 삭제 개념으로 당 제네릭 혼동으로 지우기 형식
public class CollectionsWild {
void Test(Collection<?> t){
System.out.println("Collection");
}
void Test(List<Integer> t){
System.out.println("List");
}
public static void main(String[] args) {
CollectionsWild o = new CollectionsWild();
o.Test(new ArrayList<String>());
}
}
"
List<Integer> t
는"바이트 코드에서 "목록 t"로 변환됩니다. 그렇다면 Collection을 매개 변수로 사용하는 메서드 테스트가 호출되는 이유는 무엇입니까? List로 매개 변수로 메서드를 호출해야합니다.
감사합니다.하지만 보내 주신 링크는 내가 묻고있는 것과 관련이 없습니다. –