- import java.util.*;
- class ArrayListTest2
- {
- public static void sop(Object obj)
- {
- System.out.println(obj);
- }
- public static void main(String[] args)
- {
- Set<String> set = new HashSet<String>();
- String s = new String("hello");
- String s1 = new String("hello");
- sop(set.add(s));//控制台输出true
- sop(set.add(s1));//输出false
- sop("size:" + set.size());
- for (String ss : set)
- {
- sop(ss);
- }
- }
- }
复制代码
如图
|
|