东莞广告公司东莞网站建设,万能软文范例800字,跨境电商平台有哪些分类,增城网站怎么做seoJava.util.TreeSet.contains()方法用于检查TreeSet中是否存在特定元素。因此#xff0c;本质上#xff0c;它用于检查TreeSet是否包含任何特定元素。用法:Tree_Set.contains(Object element)参数#xff1a;参数element 是TreeSet的类型。如果TreeSet中不存在此元素#xf…Java.util.TreeSet.contains()方法用于检查TreeSet中是否存在特定元素。因此本质上它用于检查TreeSet是否包含任何特定元素。用法:Tree_Set.contains(Object element)参数参数element 是TreeSet的类型。如果TreeSet中不存在此元素则需要对其进行检查。返回值如果元素存在于集合中则该方法返回true否则返回False。以下示例程序旨在说明Java.util.TreeSet.conatins()方法// Java code to illustrate contains() methodimport java.io.*;import java.util.TreeSet;public class TreeSetDemo {public static void main(String args[]){// Creating an empty TreeSetTreeSet tree new TreeSet();// Use add() method to add elements into the Settree.add(Welcome);tree.add(To);tree.add(Geeks);tree.add(4);tree.add(Geeks);tree.add(TreeSet);// Displaying the TreeSetSystem.out.println(TreeSet: tree);// Check for TreeSet in the setSystem.out.println(Does the Set contains TreeSet? tree.contains(TreeSet));// Check for 4 in the setSystem.out.println(Does the Set contains 4? tree.contains(4));// Check if the list contains NoSystem.out.println(Does the Set contains No? tree.contains(No));}}输出TreeSet: [4, Geeks, To, TreeSet, Welcome]Does the Set contains TreeSet? trueDoes the Set contains 4? trueDoes the Set contains No? false