Streams
The standard library's collection received a big update with Java 8: streams. Streams in combination with lambdas allow for functional-programming oriented code when using collections. By using streams you can transform this filtering code:
List<String> theList = new ArrayList<>(Arrays.asList("Herp", "Derp", "Merp", "Yarp"));
List<String> result = new ArrayList<>();
for (String item : theList) {
if (items.endsWith("erp") result.add(item);
}
to this:
List<String> theList = new ArrayList<>(Arrays.asList("Herp", "Derp", "Merp", "Yarp"));
List<String> result = theList.stream().filter(w -> w.endsWith("erp")).collect(Collectors.List);