0

What is the difference between the following ways of declaring ArrayList:

  1. ArrayList<String> list = new ArrayList();

  2. ArrayList list = new ArrayList<String>();

Both declarations compile, altough the first one shows warning for unchecked type.

So, why do programmers are using

ArrayList<String> list = new ArrayList<String>();

instead of the shorter version

ArrayList list = new ArrayList<String>();

CuriousGuy
  • 1,545
  • 3
  • 20
  • 42

0 Answers0