I have following collection:
List<String> listBoks = new ArrayList<>( Arrays.asList("Learn Java in a Day", "Learn Java Easily", "Learn PHP", "Learn iOS programming"));
I want to filter out this array and only get data containing Java in it.
How to filter this using the Java 8?
Example of Filter collection in Java 8
You can use the following code in Java 8:
listBoks.removeIf(s -> !s.contains("Java"));
Above code will remove all the data not containing "Java".
We have huge collection of Java util package examples check all at Java Util Examples.