-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetTest.java
More file actions
52 lines (41 loc) · 1.12 KB
/
SetTest.java
File metadata and controls
52 lines (41 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package Chapter13ConnectionInterface;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Scanner;
import java.util.Set;
public class SetTest {
public static void main(String[] args) {
//¼¯----------É¢ÁÐÂë
/*Set<String> words=new HashSet();
long totalTime=0;
System.out.print("input£º");
Scanner in=new Scanner(System.in);
while(in.hasNext()){
String word=in.next();
System.out.println(word);
long callTime=System.currentTimeMillis();
words.add(word);
callTime=System.currentTimeMillis()-callTime;
totalTime+=callTime;
System.out.println(callTime+"tootalTime:"+totalTime);
}
Iterator<String> iter=words.iterator();
for(int i=0;i<=20&&iter.hasNext();i++)
System.out.println(iter.next());
System.out.println("...");
System.out.println(words.size()+"distinctwords."+totalTime+"milliseconds.");
*/
Set<String> set=new HashSet<>();
set.add("345");
set.add("123");
set.add("dfs");
set.add("234");
set.add("123");
set.add("efewf");
set.add("fhsihc");
Iterator it=set.iterator();
while(it.hasNext()){
}
}
}