import java.util.*;
class test {
public static void main(String[] args) {
List<? super Integer> list = new ArrayList <Object> ();
list.add(new Object());
list.add(23);
list.add(23.0);
}
}
Why not compile?
import java.util.*;
class test {
public static void main(String[] args) {
List<? super Integer> list = new ArrayList <Object> ();
list.add(new Object());
list.add(23);
list.add(23.0);
}
}
Why not compile?
Originally posted by Ankit Garg:
I think its because of list.add(23.0); as it will be wrapped up into a Float object which is not a sub-class of Integer....
Please correct me as I am very weak at Generics...
Originally posted by seetharaman venkatasamy:
then wat aboout list.add(new Object())?
Originally posted by varinder mahajan:
import java.util.*;
class test {
public static void main(String[] args) {
List<? super Integer> list = new ArrayList <Object> ();
list.add(new Object());
list.add(23);
list.add(23.0);
}
}
Why not compile?
[QB][/QB]