Java Set. Contains() method: judge whether the set set contains the specified object
•
Java
contains(Object o)
Typical application
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");
}
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
