task08.task0802 - HashMap of 10 pairs
Initialization failing verify. why?
package com.codegym.task.task08.task0802;
/*
HashMap of 10 pairs
*/
import java.util.HashMap;
import java.util.Map;
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
Map m1 = new HashMap();
m1.put("watermelon", "melon");
m1.put("banana", "fruit");
m1.put("cherry", "fruit");
m1.put("pear", "fruit");
m1.put("cantaloupe", "melon");
m1.put("blackberry", "fruit");
m1.put("ginseng", "root");
m1.put("strawberry", "fruit");
m1.put("iris", "flower");
m1.put("potato", "tuber");
Map<String, String> map = new HashMap<>(m1);
//map.putAll(m1);
for (Map.Entry<String, String> pair : map.entrySet()) {
String key = pair.getKey(); // Key
String value = pair.getValue(); // Value
System.out.println(key + " - " + value);
}
}
}