Map重新组装

private static Map<String, Object> getHashMap(final Map<String, Object> map){
 final HashMap<String, Object> hMap=new HashMap<String, Object>();
 final Set<String> keySets=map.keySet();
 Iterator<?> it=keySets.iterator();
 while(it.hasNext()){
  final String key=(String) it.next();
  if(key.equals("88") || key.equals("99")){
   continue;
  }
  if(map.get(key) instanceof String){
   hMap.put(key, map.get(key).toString().trim());
  }else{
   hMap.put(key, map.get(key));
  }
 }
 return hMap;
}

 

Map

map1= new HashMap();

map1.put("2", "2");

 

Map map2=new HashMap();

map2.put("2", "2");

map2.put("88", "88");

map2.put("99", "99");

 

在此,map1与map2是相等的

你可能感兴趣的:(map,重新组装)