Java tutorial
//package com.java2s; import java.util.*; import java.util.function.Predicate; public class Main { static <E> Map<Boolean, List<E>> partitionBy(List<E> elements, Predicate<E> predicate) { //TODO Implement me Map<Boolean, List<E>> map = new HashMap<>(); List<E> trueList = new ArrayList<>(); List<E> falseList = new ArrayList<>(); for (E element : elements) { if (predicate.test(element)) { trueList.add(element); } else falseList.add(element); } map.replace(true, trueList); map.replace(false, falseList); return map; } }