金融商城快捷申请网站模板下载,肇庆seo,php门户网站源码,网站备案的规定一、HashSet集合 1 public class Demo01 {2 /*3 * Set接口#xff0c;特点不重复元素#xff0c;没索引4 * Set接口的实现类#xff0c;HashSet(哈希表)5 * 特点#xff1a;无序集合#xff0c;存储和取出的顺序不同#xff0c;没有索引#xff0c;不…一、HashSet集合 1 public class Demo01 {2 /*3 * Set接口特点不重复元素没索引4 * Set接口的实现类HashSet(哈希表)5 * 特点无序集合存储和取出的顺序不同没有索引不存储6 */7 public static void main(String[] args) {8 SetString set new HashSetString();9 set.add(wea1);
10 set.add(a2);
11 set.add(rw3);
12 set.add(ea4r);
13 set.add(awew5);
14
15 IteratorString it set.iterator();
16 while(it.hasNext()){
17 System.out.println(it.next());
18 }
19
20 System.out.println();
21 for (String string : set) {
22 System.out.println(string);
23 }
24 }
25 } 字符串对象的哈希值 1 String s1 new String(123);
2 System.out.println(s1.hashCode());
3 String s2 new String(234);
4 System.out.println(s2.hashCode()); 二、LinkHashSet集合 1 public class Demo01 {2 /*3 * LinkedHashSet基于链表的哈希表4 * 继承自HashSet5 * 特点具有顺序存储和取出的顺序相同6 * 线程不安全的集合运行速度快7 */8 public static void main(String[] args) {9 LinkedHashSetInteger link new LinkedHashSetInteger();
10 link.add(12);
11 link.add(222);
12 link.add(122);
13 link.add(322);
14 link.add(122);
15 System.out.println(link);
16 }
17 } 转载于:https://www.cnblogs.com/Nelsoner/p/6685559.html