Question: > 
> **Possible Duplicate:**  
> 
> [Type List vs type ArrayList in Java](https://stackoverflow.com/questions/2279030/type-list-vs-type-arraylist-in-java) 
> 
> 
> 

Why is it recommended to do this:

```
List<String> myArrayList = new ArrayList<String>

```

or same with Map interface and HashMap class

rather than:

```
ArrayList<String> myArrayList = new ArrayList<String>

```

Answer: 
Because the consuming code of the `myArrayList` variable won't be tied to a particular implementation of this interface.
You should not use:

```
List<String> myArrayList = new ArrayList<String>

```

Why you should use the type List instead of ArrayList (unless you really need feature of the ArrayList that is missing in the List interface) is already explained in the other answer.

But I think it is even more important to use proper names. So if you use List as type for the variable, the name should not tell that it is an ArrayList. It would be even better if the name indicated the use of the variable.

Yes, this is picky. But using good names will make it a lot easier to understand the code in a year from now and for colleagues.