Question: It may be asked somewhere but I could not find it.

Please tell me the exact difference between:

```
ArrayList list = new ArrayList();

```

and

```
ArrayList<?> list = new ArrayList();

```

I cannot figure out what is the exact difference between these two.

Thanks...

Answer: 
`ArrayList<?>` simply means "any type." In other words, any type of `ArrayList` can be assigned to such variable. That could be `ArrayList<Integers>`, `ArrayList<JButton>` or anything else. Using the wildcard alone, without the keyword super (followed by a type), means that you cannot **ADD** anything to the list defined as `ArrayList<?>`. `ArrayList` alone however, means the old style type-less `ArrayList` which you can do all sorts of operations including `add`.

```
List<?> list;
List<Integer> ints = new ArrayList<Integer>();
List<Integer> strings = new ArrayList<Integer>();
list = ints; // valid
list = strings; // valid
list.add("new"); // compile error

```

**UPDATE:**

Suppose I have following method:

```
void insert(List list) {
   // loop through list, do whatever you like
   list.add("my string"); // dangerous operation 
}

```

Now if I call `insert(ints)` compiler will generate a warning but will not prevent me of adding a String to a list of integers. Changing method to following:

```
void insert(List<?> list) {
   // loop through list, do whatever you like
   list.add("my string"); // compiler error on this dangerous operation
}

```

would prevent me of doing such an operation.
ArrayList < ? > means array list of type unknown. it is called a wildcard type.

Using the wild card, the following occurs

```
Collection<?> c = new ArrayList<String>();
c.add(new Object()); // Compile time error

```

Without the wildcard you can add whatever you like to your array