Java Map get key value set
import java.util.HashMap; import java.util.Iterator; import java.util.Set; public class Main { public static void main(String[] args) { HashMap<String, String> hMap = new HashMap<String, String>(); hMap.put("1", "CSS"); hMap.put("2", "HTML"); hMap.put("3", "Java"); Set<String> st = hMap.keySet(); Iterator<String> itr = st.iterator(); while (itr.hasNext()) System.out.println(itr.next()); // remove 2 from Set st.remove("2"); System.out.println(hMap.containsKey("2")); }/* www . j a va 2 s . co m*/ }