I want to store 4 Lists of Strings to an array within index 0-3 and be able to check wether the index is filled (!=null) or not.
For that reason I need to initialize an Array of Type List, which fails in eclipse with message "Cannot create a generic array of List":
// Does not work
List<String>[] myArray = new List<String>[4];
// Does not work
List<String>[] myArray = new ArrayList<String>[4];
Doing it like promoted at Convert an ArrayList to an object array :
ArrayList<List<String>> myArrayList = new ArrayList<List<String>>();
myArrayList.add(new ArrayList<String>());
myArrayList.add(new ArrayList<String>());
myArrayList.add(new ArrayList<String>());
myArrayList.add(new ArrayList<String>());
// Does not work
List<String>[] myArray = myArrayList.toArray(new List<String>[myArrayList.size()]);
// Does not work
List<String>[] myArray = myArrayList.toArray(new ArrayList<String [myArrayList.size()]);
But why is this not working?