-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDemoSet.java
More file actions
29 lines (22 loc) · 776 Bytes
/
Copy pathDemoSet.java
File metadata and controls
29 lines (22 loc) · 776 Bytes
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
package KienTrucCollections;
import java.util.HashSet;
import java.util.Set;
public class DemoSet {
public static void main(String[] args) {
//Khai báo đối tượng thuộc kiểu HashSet trong bộ Set
Set<String> hashSet = new HashSet<String>();
//Thêm giá trị vào HashSet
hashSet.add("PHP");
hashSet.add("Python");
hashSet.add("Java");
hashSet.add("Java");
hashSet.add("C++");
System.out.println("Các phần tử của Set");
System.out.print("\t" + hashSet + "\n");
System.out.println(hashSet.size());
//Duyệt giá trị trong Collection
for (String programmingName : hashSet){
System.out.println(programmingName);
}
}
}