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: 
There is no difference in the behaviour.

The real difference is in the way that the compiler treats them. In the first case, you are telling the compiler "treat this as a *raw* type" and don't try to do any generic static typing. In the second case, you are saying "treat this as a generic type" ... but that the actual type parameter is "some type that we want to avoid specifying here".

And note that the `<?>` wildcard syntax cannot be used where a definite type is required.

@SJuan76 commented:

> 
> "(I guess they didn't add the feature just to get some code to produce compilation errors)"
> 
> 
> 

Well, actually you could say that that *is* that they did. Or more precisely, they left the old form so that old (pre-Java 5) code would continue to compile *without* compilation errors using a Java 5+ compiler.
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