Day7 Colection Framework
Day7 Colection Framework
Day7 Colection Framework
i/p: 1 2 3 4 5 6
2 4 5 9 10
o/p: 2 4 5
98 -45 20 5 35
o/p: -45 5 20
classname: ClassCollectionFramework1
*/
import java.util.HashSet;
/*Write a java program to print student name and his ID in sorted order by name
hm.put(keys[i],values[i])
o/p:
Anand: ID102
Kiran: ID100
Ramesh:ID101
classname: ClassCollectionFramework2
*/
import java.util.*;
// Iterate over the sorted map and print student names and IDs
for (Map.Entry<String, String> entry : sortedMap.entrySet()) {
System.out.println(entry.getKey() + ": " + entry.getValue());
}
}
}
/*
Write a Java Program to rename a key from the given HashMap
i/p:
apples
pomegranates
o/p:
bananas 20
mangoes 15
oranges 200
pomegranates 10
watermelons 50
classname: ClassHashMapRenameKey
*/
import java.util.*;