Question: When instantiating ArrayLists I am used to seeing code like this

```
ArrayList<Type> arr = new ArrayList<Type>();

```

or

```
ArrayList<Type> arr = new ArrayList<>();

```

however today I have come across an instantiation of ArrayList that looks like this:

```
ArrayList<Type> arr = new <Type>ArrayList();

```

what is going on, and why does that give an "unsafe operations" compile warning?

Answer: 
I've just tried:

```
ArrayList<Integer> arr = new <String>ArrayList();

```

And got the same warning (not an error!). Looks like the compiler ignores1 the generics after the `new` keyword and before the `ArrayList`. It's just like writing:

```
ArrayList<Integer> arr = new ArrayList();

```

1 I'm not sure if it really "ignores" that, I'll be glad if someone confirms/correct me
The code, it does nothing!

```
int a = new <String>Integer(5);

```

It also compiles but generates a warning of "unused generics".

So basically it is useless but not bad enough to generate an error by default it seems. Either way your arraylist is NOT properly generified here.

Please note that generics are compiled away anyway so at the bytecode level it probably won't look any different. I have looked in eclipse for a way to turn this into an error instead of warning but no luck there.

**UPDATE**

This answer boils down to the same as the other one which is currently at +5, so why is mine downvoted? Please leave a comment if you downvote.