From the API:
addAll(Collection<? extends E> c) : adds all the elements in the specified collection to this collection (optional operation).
Here's an example using List , which is an ordered collection:
List<Integer> nums1 = Arrays.asList(1,2,-1); List<Integer> nums2 = Arrays.asList(4,5,6); List<Integer> allNums = new ArrayList<Integer>(); allNums.addAll(nums1); allNums.addAll(nums2); System.out.println(allNums);
On int[] vs Integer[]
While int is autoboxable before Integer , a int[] NOT "autoboxing" to Integer[] .
Thus, you get the following behavior:
List<Integer> nums = Arrays.asList(1,2,3); int[] arr = { 1, 2, 3 }; List<int[]> arrs = Arrays.asList(arr);
Related Questions
- Arrays.asList () not working as it should?
polygenelubricants
source share