3번
4번 - 지네릭 메서드 타입 호출 생략가능
2번 - 빈 지네릭스 올 수 없음 → 빈 지네릭스는 생략된 것이라 가능
3번 - 타입이 Fruit의 자손이어야 함
4번 - 타입이 Fruit의 자손이어야 함
5번 - 참조변수에 타입을 생략할 수 없음 → 생략할 수 있지만 바람직하지 않음
7번 - 타입이 Fruit의 자손이어야 함 new 연산자는 타입이 명확해야함
public static ArrayList<? extends Product>
merge(ArrayList<? extends Product> list, ArrayList<? extends Product> list2) {
ArrayList<? extends Product> newList = new ArrayList<>(list);
newList.addAll(list2);
return newList;
}
public static <T extends Product> ArrayList<T>
merge(ArrayList<T> list, ArrayList<T> list2) {
ArrayList<T> newList = new ArrayList<>(list);
newList.addAll(list2);
return newList;
}