declare multiple arraylists

Tags:



is it possible to declare 2 array lists in the same line? e.g:

List<String> mm= new ArrayList<String>();
List<String> kk= new ArrayList<String>();

Is it then possible to do something like:

List<String> mm,kk= new ArrayList<String>();

Obviously, I get a compile error when I do the above, and was wondering how could one declare 2 lists in the same line.

Answer

If you want that, you should do:

List<String> list_1 = new ArrayList<String>(), list_2 = new ArrayList<String>();


Source: stackoverflow