If you have specifically two conditions resulting in two sub-lists and they are alternate that is only one of the two conditions may be true, you could use OR in filter
or Predicate.or
and then use Collectors.partitioningBy
by either condition:
Map<Boolean, List<String>> sublistMap = list
.stream()
.filter(condition1.or(condition2))
.collect(Collectors.partitioningBy(condition1, Collectors.toUnmodifiableList()));
List<String> sublist1 = sublistMap.get(Boolean.TRUE); // condition1
List<String> sublist2 = sublistMap.get(Boolean.FALSE); // condition2
Test
List<String> list = Arrays.asList("a", "b", "cc", "ddd", "aaaa", "vvv", "oo");
Predicate<String> condition1 = (s) -> s.contains("o");
Predicate<String> condition2 = (s) -> s.contains("a");
System.out.println(sublist1);
System.out.println(sublist2);
Output:
[oo]
[a, aaaa]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…