public static void main(String[] args) throws Exception {
Map<String, String> map = geDictionary();
String str = "love";
if (map.containsKey(str)) {
System.out.println(map.get(str));
} else {
System.out.println("词库里没有这个词");
}
}
public static Map<String, String> geDictionary() {
Map<String, String> map = new HashMap<String, String>();
map.put("dictionary", "字典");
map.put("map", "地图");
map.put("love", "爱");
map.put("cat", "猫");
map.put("dog", "狗");
map.put("bird", "鸟");
return map;
}