This example will generate even numbers from a provided range. In the snippets below all even numbers between 1 and 10 will be displayed.
Using an Intstream we will create a range of numbers from 1 to 10. Next, using a lambda expression to create a java predicate that will return true if the number is even. Passing it to IntStream.filter it will return all even numbers for the given range.
Using guava we will create a ContiguousSet passing in a Range from 1 to 10. Creating a guava predicate that will return true if the given number is even we will pass it to the Iterables.filter method to return all even numbers within the range.