import java.util.*;
public class D1 {
static void sop(Object o) {
System.out.println(o);
}
public static void main(String args[]) {
Map<String, String> map = new HashMap<String, String>();
map.put("Tom", "CoreJava");
map.put("John", "Oracle");
map.put("Susan", "Oracle");
map.put("Jerry", "JDBC");
map.put("Jim", "Unix");
map.put("Kevin", "JSP");
map.put("Lucy", "JSP");
Set<String> set = map.keySet();
for (String s : set)
sop(s + ":" + map.get(s));
map.put("Allen", "JDBC");
map.put("Lucy", "CoreJava");
sop("-------");
for (String s1 : set)
sop(s1 + ":" + map.get(s1));
sop("--------");
Set<Map.Entry<String, String>> entrySet = map.entrySet();
Iterator<Map.Entry<String, String>> it = entrySet.iterator();
while (it.hasNext()) {
Map.Entry<String, String> mapEntry = it.next();
if (mapEntry.getValue() == "JSP") {
sop(mapEntry.getKey());
}
sop("Key " + mapEntry.getKey() + " Value:" + mapEntry.getValue());
}
}
}
public class D1 {
static void sop(Object o) {
System.out.println(o);
}
public static void main(String args[]) {
Map<String, String> map = new HashMap<String, String>();
map.put("Tom", "CoreJava");
map.put("John", "Oracle");
map.put("Susan", "Oracle");
map.put("Jerry", "JDBC");
map.put("Jim", "Unix");
map.put("Kevin", "JSP");
map.put("Lucy", "JSP");
Set<String> set = map.keySet();
for (String s : set)
sop(s + ":" + map.get(s));
map.put("Allen", "JDBC");
map.put("Lucy", "CoreJava");
sop("-------");
for (String s1 : set)
sop(s1 + ":" + map.get(s1));
sop("--------");
Set<Map.Entry<String, String>> entrySet = map.entrySet();
Iterator<Map.Entry<String, String>> it = entrySet.iterator();
while (it.hasNext()) {
Map.Entry<String, String> mapEntry = it.next();
if (mapEntry.getValue() == "JSP") {
sop(mapEntry.getKey());
}
sop("Key " + mapEntry.getKey() + " Value:" + mapEntry.getValue());
}
}
}