How to process object failed to satisfy the filter in java 8 stream

  • A+

I am trying to process object which is failed to satisfy the filter condition in the stream.

List<Integer> list = Arrays.asList(1,23,43,12,4,5); i -> i > 10).collect(Collections.toList); 

This will return a list of Object greater than 10. but I also want to process the objects which are unable to satisfy the condition (>10).

Thank You.


Map<Boolean, List<Integer>> map =               .collect(Collectors.partitioningBy(i > 10));   map.get(false/true).... do whatever you want with those that failed or not 


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: