자바의 제네릭은 어떻게 이전 버전과 호환되는 걸까?
자바 궁금증
Last updated
자바 궁금증
Last updated
// 컴파일 전
class Example {
static Juice makeJuice(FruitBox<? extends Fruit> box) {
String tmp = "";
for(Fruit f : box.getList()) {
tmp += f + " ";
}
return new Juice(tmp);
}
}
// 컴파일 후
class Example {
static Juice makeJuice(FruitBox box) {
String tmp = "";
Iterator it = box.getList().iterator();
while(it.hasNext()) {
tmp += it.next() + " ";
}
return new Juice(tmp);
}
}