123456789101112131415161718192021222324 |
- package J20250722;
- import java.util.HashSet;
- import java.util.Set;
- /**
- * @author WanJl
- * @version 1.0
- * @title Demo05_Set
- * @description
- * @create 2025/7/22
- */
- public class Demo05_Set {
- public static void main(String[] args) {
- Set<String> set=new HashSet<>();
- set.add("Hello");
- set.add("zhangsan");
- set.add("wangwu");
- //遍历 foreach
- for(String s: set){
- System.out.println(s);
- }
- }
- }
|