user user - 1 year ago 42
Java Question

What is the type String[]?

I came across code that declared the following

List <String[]> l1 = new ArrayList<String[]>();

I'm unsure what this is a list of. How would you add an instance of String[] to the list l1?

List <String[]> l1 = new ArrayList<String[]>();

Is a list of arrays of strings. Could be considered equivalent to String[][] except the list can be added to and removed from like this:

String[] myStringArray = new String[]{ "1","2","3"};
List<String[]> myListOfStringArrays = new List<>();

You can even make it a String[][] by calling myListOfStringArrays.ToArray();