-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyCollection.java
More file actions
73 lines (66 loc) · 2.14 KB
/
MyCollection.java
File metadata and controls
73 lines (66 loc) · 2.14 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import java.util.HashMap;
import java.util.Map;
// public class MyCollection {
// public static void main(String[] args) {
// // Collection<Integer> Nums = new ArrayList<Integer>();
// // To get the index of the values we can use the List:
// List<Integer> Nums = new ArrayList<Integer>();
// Nums.add(10);
// Nums.add(15);
// Nums.add(25);
// Nums.add(21);
// System.out.println(Nums.get(1));
// for (int n : Nums) {
// System.out.println(n);
// }
// }
// };
// public class MyCollection {
// public static void main(String[] args) {
// Set<Integer> Numbers = new HashSet<Integer>();
// Numbers.add(25);
// Numbers.add(26);
// Numbers.add(21);
// Numbers.add(125);
// Numbers.add(85);
// Numbers.add(25);
// for (int N : Numbers) {
// System.out.println(N);
// }
// }
// }
// public class MyCollection {
// public static void main(String[] args) {
// Set<Integer> Numbers = new TreeSet<Integer>();
// Numbers.add(25);
// Numbers.add(26);
// Numbers.add(21);
// Numbers.add(125);
// Numbers.add(85);
// Numbers.add(25);
// // for (int N : Numbers) {
// // System.out.println(N);
// // }
// // You can use the Iterator to print the values
// Iterator<Integer> values = Numbers.iterator();
// System.out.println(values.next());
// while (values.hasNext()) {
// System.out.println(values.next());
// }
// }
// }
public class MyCollection {
public static void main(String[] args) {
Map<String, Integer> MyMarks = new HashMap<>();
MyMarks.put("Maths", 25);
MyMarks.put("Science", 26);
MyMarks.put("Social", 27);
MyMarks.put("Maths", 48);
System.out.println(MyMarks);
System.out.println(MyMarks.get("Social"));
System.out.println(MyMarks.keySet());
for (String KEYNAME : MyMarks.keySet()) {
System.out.println(KEYNAME + " " + MyMarks.get(KEYNAME));
}
}
}