public static void main(String args[]) {
List<Double> doubleList = new ArrayList<>();
doubleList.add(new Double(101.215D));
doubleList.add(new Double(102.215D));
doubleList.add(new Double(103.215D));
printIntValue1(doubleList);
System.out.println("*******");
printIntValue2(doubleList);
}
//bounded parameter
public static <T extends Number> void printIntValue1(List<T> list){
for(T num : list){
System.out.println(num.intValue());
}
}
//Wildcard parametr
public static void printIntValue2(List<? extends Number> list){
for(Number num : list){
System.out.println(num.intValue());
}
}
As in above two methods, both gives same results. Can anybody tell me if all the work already done by bounded type then why the concept of wildcard is there? Does wildcard do some other work that bounded types don't?