I came to know the Unbounded Wild card but I didn't understand usage of it in realworld. In Below program using and with out using this Unbounded Wildcard will be same at compile time.Then why we need Unbounded wild cards ?Please help to understand.
public class UnboundedWildCards {
public static void main(String args[])
{
List<Integer> intLst = new ArrayList<Integer>();
intLst.add(1);
intLst.add(11);
List<Double> doubleLst = new ArrayList<Double>();
doubleLst.add(1.1);
doubleLst.add(11.11);
List lst = new ArrayList();
lst.add(new Object());
lst.add(new Double(2.3));
lst.add(new Integer(2));
print(intLst);
print(doubleLst);
print(lst);
unBoundprint(intLst);
unBoundprint(doubleLst);
unBoundprint(lst);
}
public static void print(List lst)
{
for(Object o : lst)
System.out.println(o);
}
public static void unBoundprint(List<?> lst)
{
for(Object o : lst)
System.out.println(o);
}
}