How to use ArrayList.addAll()?
问题 I want to fill an ArrayList with these characters +,-,*,^ etc. How can I do this without having to add every character with arrayList.add() ? 回答1: Collections.addAll is what you want. Collections.addAll(myArrayList, '+', '-', '*', '^'); Another option is to pass the list into the constructor using Arrays.asList like this: List<Character> myArrayList = new ArrayList<Character>(Arrays.asList('+', '-', '*', '^')); If, however, you are good with the arrayList being fixed-length, you can go with