List<?> a= new LinkedList<?>();
843793Mar 23 2010 — edited Mar 28 2010import java.util.*;
public class Test1 {
public static void main (String as[]){
List<?> a= new LinkedList<?>();
a.add("sd");
a.add(1);
a.add(new Integer(3));
a.add(new Object());
Iterator itr =a.iterator();
while(itr.hasNext()){
System.out.println(itr.next());
}
Object[] b= a.toArray();
for(Object o :b){
System.out.println(o.toString());
}
}
}
I have a question the above code works if the parameterised type is <Object> or without <> , but when i use <?> it results in Error
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
* Cannot instantiate the type LinkedList<?>*
so where can i use this <?> and what it exactly mean ??
Thanks in advance