import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.Iterator; class Program03 { public static void main(String args[]) { HashMap m = new HashMap(); m.put("alma", "apple"); m.put("asztal", "table"); m.put("szék", "chair"); System.out.println(m.get("asztal")); System.out.println(m.containsKey("alma")); System.out.println(m.containsValue("apple")); Set> h = m.entrySet(); System.out.println("------------------"); Iterator> i = h.iterator(); while(i.hasNext()) { Map.Entry elem = i.next(); System.out.println("Kulcs: "+elem.getKey()+ "\térték: "+ elem.getValue()); } System.out.println("------------------"); System.out.println("------------------"); for (Map.Entry entry : m.entrySet()) { System.out.println(entry.getKey() + "\t" + entry.getValue()); } System.out.println("------------------"); String magyar = m.get("alma"); System.out.println("Az alma jelentése: " + magyar); Set h2 = m.keySet(); System.out.println("Van-e alma: " + h2.contains("alma")); String s = m.remove("asztal"); System.out.println("Töröleve ez: " + s); //Eredmény: table m.clear(); System.out.println(m.size()); } }