ArrayList list = new ArrayList();
We are declaring an array list that can accept any type of objects.
For example:
list.add(new Dog());
list.add(new Person());
list.add("Test");
For ArrayList<?> list = new ArrayList();
We are declaring an array list using generics that can accept any object using the wild card ?
The catch here is that we cannot add elements to that array list.
This code will not even compile:
ArrayList<?> list = new ArrayList();
list.add("test");
Update:
I think the only purpose of the ? wild card in generics is to be coupled by the extends keyword.
ArrayList<? extends Animal> list = new ArrayList<Dog>();
In that case we add any object to list that extends the Animal object
or to be passed to as a parameter to a method.
public void foo(List<?> list) { }
In that case the method foo cannot add objects to the parameter list