Skip to content

Commit 205d259

Browse files
committed
6일차 collection framework - 2
1 parent c97ab63 commit 205d259

3 files changed

Lines changed: 64 additions & 5 deletions

File tree

‎.idea/workspace.xml‎

Lines changed: 15 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package collection;
2+
3+
import java.util.HashSet;
4+
import java.util.Set;
5+
6+
public class HashSetTest {
7+
8+
public static void main(String[] args) {
9+
Set<String> s = new HashSet<>();
10+
11+
String s1 = new String("도우너");
12+
String s2 = new String("도우너");
13+
14+
s.add("둘리");
15+
s.add("마이콜");
16+
s.add("또치");
17+
s.add(s1);
18+
// s.add(s2);
19+
20+
System.out.println(s.size());
21+
System.out.println(s.contains(s2));
22+
23+
//순회
24+
for(String str : s) {
25+
System.out.println(str);
26+
}
27+
}
28+
29+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package collection;
2+
3+
import java.util.HashSet;
4+
import java.util.Set;
5+
6+
public class HashSetTest02 {
7+
8+
public static void main(String[] args) {
9+
Set<Gugudan> set = new HashSet<>();
10+
11+
set.add(new Gugudan(2, 3));
12+
set.add(new Gugudan(9, 9));
13+
set.add(new Gugudan(3, 2));
14+
15+
for(Gugudan g: set) {
16+
System.out.println(g);
17+
}
18+
}
19+
20+
}

0 commit comments

Comments
 (0)