Java tutorial
//package com.java2s; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import java.util.*; public class Main { public static void filterSets() { Set<String> words = new HashSet<>(); words.add("1"); words.add("2"); words.add("3"); Set<String> filteredSet = Sets.filter(words, new Predicate<String>() { @Override public boolean apply(String input) { return input.equals("1"); } }); System.out.println(Iterables.toString(filteredSet)); } }