addAll add another set of the elements inside
add add the entire set comprises []
Stream operations into two lis
1 public class Test { 2 public static void main(String[] args) { 3 4 List<String> destList = Collections.synchronizedList(new ArrayList<>(Arrays.asList("foo"))); 5 6 List<String> newList = Arrays.asList("0", "1", "2", "3", "4", "5"); 7 8 newList.stream().sequential().collect(Collectors.toCollection(() -> destList)); 9 10 11 12 //newList + destList 的内容 13 //结果 [foo, 0, 1, 2, 3, 4, 5] 14 System.out.println(destList); 15 16 17 System.out.println("=========================================="); 18 19 List<String> listOne = new ArrayList<String>(); 20 listOne.add("333"); 21 listOne.add("666"); 22 listOne.add("999"); 23 24 List<String> listTwo = new ArrayList<String>(); 25 listTwo.add("A"); 26 listTwo.add("B"); 27 listTwo.add ( "C" ); 28 29 30 31 is // the addAll add another set of elements inside 32 // results [333, 666, 999, A, B, C] 33 is listOne.addAll (listTwo); 34 is the System .out.println (in listOne); 35 36 37 [ // the Add add the entire set comprises [] 38 @ results [A, B, C, [333, 666, 999, A, B, C]] 39 listTwo.add ( listOne.toString ()); 40 System.out.println (listTwo); 41 is 42 is 43 is 44 is } 45 46 is }