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"); } }运行结果如下:
Copyright © 广州京杭网络科技有限公司 2005-2025 版权所有 粤ICP备16019765号
广州京杭网络科技有限公司 版权所有