-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOther2.java
More file actions
36 lines (26 loc) · 925 Bytes
/
Other2.java
File metadata and controls
36 lines (26 loc) · 925 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
30
31
32
33
34
35
36
package java_exercises_others;
//2. Utwórz zbiór Set implementujący HashSet.
// •Dodaj trzy imiona do zbioru
// •Dodaj jedno z tych imion ponownie
// •Sprawdź rozmiar zbioru
import java.util.HashSet;
import java.util.Set;
public class Other2 {
public static Set<String> ex2() {
Set<String> setExamples = new HashSet<>();
setExamples.add("Jan");
setExamples.add("Jakub");
setExamples.add("January");
System.out.println("Size: " + setExamples.size());
setExamples.add("Jadwiga");
System.out.println("Size: " + setExamples.size());
return setExamples;
}
public static void main(String[] args) {
// Set<String> returnSetExamples = setExamples;
Set<String> returnSetExamples = ex2();
for (String name : returnSetExamples){
System.out.println("Hello " + name);
}
}
}