I was just wondering what is the difference between following two approach of converting List to Array.
List<String> test = new ArrayList<String>();
test.add("AB");
test.add("BC");
test.add("CD");
test.add("DE");
test.add("EF");
String[] testarray = test.toArray(new String[0]); // passing 0 as Array size
And below one :
List<String> test = new ArrayList<String>();
test.add("AB");
test.add("BC");
test.add("CD");
test.add("DE");
test.add("EF");
String[] testarray = test.toArray(new String[test.size()]); // passing list's size
I got the same output for testarray on console.