void (List<String> strings) { Map<Boolean, LinkedHashSet<String>> map = new HashMap<>(); map.put(false, new LinkedHashSet<>()); map.put(true, new LinkedHashSet<>()); for (String s : strings) { map.get(s.length() > 2).add(s); } System.out.println(map); }