-
Notifications
You must be signed in to change notification settings - Fork 0
/
Collection
34 lines (29 loc) · 908 Bytes
/
Collection
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
import java.util.*;
public class CollectionsExample {
public static void main(String[] args) {
// ArrayList
List<String> list = new ArrayList<>();
list.add("Java");
list.add("Python");
list.add("C++");
System.out.println("ArrayList: " + list);
// LinkedList
List<Integer> numbers = new LinkedList<>();
numbers.add(1);
numbers.add(2);
numbers.add(3);
System.out.println("LinkedList: " + numbers);
// HashMap
Map<String, Integer> map = new HashMap<>();
map.put("apple", 10);
map.put("banana", 20);
map.put("orange", 30);
System.out.println("HashMap: " + map);
// HashSet
Set<String> set = new HashSet<>();
set.add("apple");
set.add("banana");
set.add("orange");
System.out.println("HashSet: " + set);
}
}