package J20250724.demo01;

import java.util.HashSet;
import java.util.TreeSet;

/**
 * @author WanJl
 * @version 1.0
 * @title Demo01
 * @description
 * @create 2025/7/24
 */
public class Demo01 {
    public static void main(String[] args) {
        HashSet<Integer> set=new HashSet<>();
        set.add(5);
        set.add(2);
        set.add(5);
        set.add(9);
        set.add(2);
        set.add(7);
        boolean b = set.contains(9);
        System.out.println(set.size());
        for (Integer i:set){
            System.out.println(i);
        }

        TreeSet<Integer> set1=new TreeSet<>();
        set1.add(1);
        set1.add(3);
        Integer first = set1.first();   //获取第一个元素
        System.out.println(first);
        System.out.println(set1.last());//获取最后一个元素
        for (Integer i:set1){
            if (i>10){
                System.out.println(i);
            }
        }

    }
}
