public static void main(String[] args)
    {
        HashMap<String, String> test_map = new HashMap<String, String>();
        test_map.put("1", "test1");
        test_map.put("2", "test2");
        test_map.put("3", "test3");
        test_map.put("4", "test4");
        
        Set mapset = test_map.entrySet();
        Iterator iterator = mapset.iterator();
        while(iterator.hasNext())
        {
            Map.Entry mapentry = (Map.Entry)iterator.next();

            String key = mapentry.getKey().toString();
            String value = mapentry.getValue().toString();
            
            System.out.printf("key: %s value:%s\r\n", key, value);

        }
        
        System.out.printf("***************deleting************\r\n");
        
        Iterator<Map.Entry<String, String>> it = test_map.entrySet().iterator();
        while(it.hasNext())
        {
            Map.Entry<String, String> entry= it.next();
            String key= entry.getKey();
            int k = Integer.parseInt(key);
            if(k%2==1)
            {
                System.out.printf("delete key:%s value:%s\r\n", key, entry.getValue());
                it.remove(); //OK

            }
        }
        
        System.out.printf("***************result************\r\n");
        
        iterator = mapset.iterator();
       
        while(iterator.hasNext())
        {
            Map.Entry mapentry = (Map.Entry)iterator.next();
            String key = mapentry.getKey().toString();
            String value = mapentry.getValue().toString();
            
            System.out.printf("key: %s value:%s\r\n", key, value);

        }
        
    }