//Skip to content
- import java.util.HashMap;
- import java.util.HashSet;
- import java.util.Iterator;
- import java.util.LinkedHashMap;
- import java.util.Map;
- import java.util.Set;
- import java.util.TreeMap;
-
- public class HashMapDemo {
-
- public static void main(String[] args) {
-
- HashMap<String, Integer>hMap=new HashMap<>();
- hMap.put("Sujan", 1);
- hMap.put("Shakil", 2);
- hMap.put("Shimul", 3);
- System.out.println("Hashmap:-");
- print(hMap);
-
- LinkedHashMap<String, Integer>lMap=new LinkedHashMap<>();
- lMap.put("Sumon", 2);
- lMap.put("Shipon", 1);
- lMap.put("Saiful", 4);
- System.out.println("\nLinkedhashmap:-");
- lprint(lMap);
-
- TreeMap<String, Integer>tMap=new TreeMap<>();
- tMap.put("ABC", 0);
- tMap.put("XYZ", 1);
- System.out.println("\nTreemap:-");
- tprint(tMap);
-
-
- }
- private static void print(HashMap<String, Integer>hashMap) {
- for(Map.Entry x:hashMap.entrySet()){
- System.out.println("Key: "+x.getKey()+" Value: "+x.getValue());
- }
-
- }
-
- private static void tprint(TreeMap<String, Integer>treeMap) {
- for(Map.Entry y:treeMap.entrySet()){
- System.out.println("Key: "+y.getKey()+" Value: "+y.getValue());
- }
-
- }
-
- private static void lprint(LinkedHashMap<String, Integer>lHashMap) {
- for(Map.Entry z:lHashMap.entrySet()){
- System.out.println("Key: "+z.getKey()+" Value: "+z.getValue());
- }
-
- }
-
- }
I am Md Abdullah Al Hasan. I have completed my graduation in Computer Science and Engineering from Jashore University of Science and Technology.
0 Comments:
Post a Comment