contains(Object o)
引數說明:public static void main(String[] args){ Set set = new HashSet(); set.add(new Date()); set.add("apple"); set.add(new Socket()); boolean contains = set.contains("apple"); if(contains){ System.out.println("Set集合包含字串apple"); }else{ System.out.println("Set集合不包含字串apple"); } }執行結果如下: