package CHAPTER09;

import java.util.HashSet;

public class C9_10_HashSetExam {
    public static void main(String[] args) {
        // HashSet 생성 (문자열 저장)
        HashSet<String> fruits = new HashSet<>();

        // 요소 추가
        fruits.add("Apple");
        fruits.add("Banana");
        fruits.add("Orange");
        fruits.add("Apple"); // 중복된 요소 추가 시 무시됨
        System.out.println("초기 HashSet: " + fruits);

        // 요소 제거
        fruits.remove("Banana");
        System.out.println("Banana 제거 후 HashSet: " + fruits);

        // 특정 요소 포함 여부 확인
        boolean containsApple = fruits.contains("Apple");
        System.out.println("Apple 포함 여부: " + containsApple);

        // HashSet 크기 확인
        System.out.println("HashSet 크기: " + fruits.size());

        // 모든 요소 출력
        System.out.println("모든 요소 출력:");
        for (String fruit : fruits) {
            System.out.println(fruit);
        }

        // HashSet 비우기
        fruits.clear();
        System.out.println("HashSet 비운 후: " + fruits);
    }
}
