import java.util.*; public class Test { boolean containsDuplicates(Object[] array) { Set seen = new HashSet(); for (Object o : array) { // should be flagged if (seen.contains(o)) return true; } return false; } void foo(List l) { // should not be flagged l.contains(23); } void bar(Collection> c) { for (List l : c) // should not be flagged l.contains(c); } List l = new LinkedList(); List getL() { return l; } { getL().add(23); // should not be flagged l.contains(23); } void add23(List l) { l.add(23); } void baz() { List l = new LinkedList(); add23(l); // should not be flagged l.contains(23); } { List l2 = new LinkedList(l); // should not be flagged l2.contains(23); List l3 = new LinkedList(); l3.add(42); // should not be flagged l3.contains(23); List l4 = new LinkedList(); l4.addAll(l); // should not be flagged l4.contains(23); Stack l5 = new Stack(); l5.push(23); // should not be flagged l5.contains(23); } List g() { List bl = new ArrayList(); // should be flagged bl.contains(false); return bl; } // should not be flagged private Set sneakySet = new LinkedHashSet() {{ add(23); add(42); }}; boolean inSneakySet(int x) { return sneakySet.contains(x); } }