Hi,
I came across a question in the Whizzlab
test, whose answer I have found confusing.
According to it this code would compile but with warnings:
public static void main(String[] args) {
List<? extends Object> ll = new LinkedList<? extends Object>();
ll.add("String");
ll.add(4);
ll.add(true);
ll.toString();
} but this one would compile without warnings:
public static void main(String[] args) {
List<Object> ll = new LinkedList<Object>();
ll.add("String");
ll.add(4);
ll.add(true);
ll.toString();
} My understanding is that:
List<Object> ll = new LinkedList<Object>(); mean the same thing as
List<? extends Object> ll = new LinkedList<? extends Object>(); but not according to Whizzlab
Could anyone clarify please?
Thank you
Katrin
Katrin
SCJP 5.0, SCWCD, SCBCD, Oracle Certified Master Enterprise Architect