Skip to content
Advertisement

Filtering using predicates

I have used predicates before to filter collections as follows:

JavaScript

For the above I used Java 8 and the latest Guava library. However I’m working on an assignment where I am restricted to Java 6 and version 13.0.1 of Guava with zero chance of getting them to update their maven repo.

I am struggling to get a similar type of predicate done in Java 6 as the use of lambda expressions is not allowed.

I would appreciate any help to port this code to Java 6. Thanks

Advertisement

Answer

The typical, pre-Java-8 way of doing things looks like

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement