What is the difference between the two data structures defined below?
The second one is an ArrayList, whose elements have type ‘String’. But what is the first data structure?
The initializations would also be different. Can anyone give an example here?
ArrayList<String>[] temp1;
ArrayList<String> temp2;
ArrayList<String>[] temp1;: This is an Array of ArrayList’s that are containing StringsArrayList<String> temp2;: This is an ArrayList containing StringsIf you want an ArrayList of Arrays of Strings, you would have to do a
ArrayList<String[]> temp3;. Note the position of the different brackets.To initialize: