Skip to content

Commit e0134e5

Browse files
committed
HashSet Example
1 parent 4b39511 commit e0134e5

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package CollectionsFramework.Day_2;
2+
3+
import java.util.HashSet;
4+
import java.util.Set;
5+
6+
public class HashSetExample {
7+
8+
public static void main(String[] args) {
9+
Set<String> fruits = new HashSet<>();
10+
11+
fruits.add("Apple");
12+
fruits.add("Mango");
13+
fruits.add("Banana");
14+
fruits.add("Apple"); // duplicate
15+
16+
System.out.println(fruits); // Unordered, no duplicates
17+
}
18+
}

0 commit comments

Comments
 (0)