, .
Holger . , , , , - . , , ,
List<String> modified = list.parallelStream()
.filter(s -> !s.equals("b-b"))
.map(s -> s + "-" + s)
.map(s -> s.substring(2))
.collect(toList());
[a, b, c]. .
, [c, a] [a, c]. , . java.util.stream. , , . , ( ) - .
, , HashSet ArrayList. , HashSet, , , . HashSet, , , , , , .
, List, . [a, b, c], , , "a" "b", "c". .
, . , , :
List<String> list = Arrays.asList("c", "b", "a");
List<String> modified = list.parallelStream()
.map(s -> s + "-" + s)
.filter(s -> !s.equals("b-b"))
.map(s -> s.substring(2))
.collect(toList());
, [c, a]. :
List<String> list = Arrays.asList("c", "b", "a");
Set<String> set = new HashSet<>(list);
List<String> modified = set.parallelStream()
.map(s -> s + "-" + s)
.filter(s -> !s.equals("b-b"))
.map(s -> s.substring(2))
.collect(toList());
[a, c]. (, , ) , undefined, , .
( , , HashSet - , -.)
"", . . , . ( , , , , , , .) :
List<Integer> list1 = Collections.synchronizedList(new ArrayList<>());
List<Integer> list2 =
IntStream.range(0, 10)
.parallel()
.boxed()
.peek(i -> list1.add(i))
.collect(toList());
System.out.println(list1);
System.out.println(list2);
:
[5, 6, 2, 3, 4, 8, 9, 7, 0, 1]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
2, 1 . list1 run run, list2 .
, :
.