Created
February 9, 2011 05:29
-
-
Save csamuel/817936 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.common.base.Predicate; | |
import com.google.common.collect.Iterables; | |
import com.google.common.collect.Lists; | |
public class GuavaEvensFilter { | |
public static void main (String [] args) | |
{ | |
// Prints "[2, 4]" | |
System.out.println( | |
Iterables.filter( | |
Lists.newArrayList(1, 2, 3, 4), | |
new Predicate<Integer>() { | |
public boolean apply(Integer x) { | |
return x % 2 == 0; | |
} | |
}) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment