ArrayList frequent use of add () too much trouble, but: ArrayList <String> strList = new ArrayList <String> () { "sing", "jump", "rap", "play basketball"}; // not possible, how do?

Use Arrays of asList () method, the array is converted into a set, and then addAll () method to add the entire list, one step:

ArrayList<String> sList = new Array<String>();

sList.addAll (Arrays.asList ( "sing", "jump", "rap", "basketball"));

Guess you like

Origin www.cnblogs.com/bear-19970220/p/11260413.html