Possible Duplicate:
What’s the difference between <?> and <? extends Object> in Java Generics?
I found that List<?>and List<? extends Object> act in the same way. As for me, there are no difference between them. If I am not right, can you explain me the difference?
import java.util.ArrayList;
import java.util.List;
public class TestClass {
static void func1(List<?> o, Object s) {
    o.add(null); // only null
    o.add(s); // wrong
    o.get(0);  // OK
}
static void func2(List<? extends Object> o, Object s) {
    o.add(null); // only null
    o.add(s); // wrong
    o.get(0); // OK
}
public static void main(String[] args) {
    func1(new ArrayList<String>(), new Integer(1));
    func2(new ArrayList<String>(), new Integer(1));
    List<? extends Object> list1 = new ArrayList<Object>();
    List<?> list2 = new ArrayList<Object>();
    List<? extends Object> list3 = new ArrayList<String>();
    List<?> list4 = new ArrayList<String>();
}
}
 
     
     
     
     
    