Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Map<Integer, List<String>> lengthMap = new HashMap<>();
for(String string : strings)
List<String> sameLength = null;
Integer length = string.length();
if(lengthMap.get(length) == null)
sameLength = new ArrayList<>();
lengthMap.put(length, sameLength);
List<String> sameLengthString = lengthMap.get(length);
return lengthMap;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment