import java.util.*; class AAA { boolean addIntoTwoSets(Set set1, Set set2, String value) { return set1.add(value) && set2.add(value); } void usage() { Set s1 = new HashSet<>(); Set s2 = new HashSet<>(); addIntoTwoSets(s1, s2, "foo"); } }