你上传的不对:
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.Map;
- import java.util.Set;
- public class Demo3 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Map<Integer, String> map = new HashMap<Integer, String>();
- map.put(1, "90");
- map.put(2, "80");
- map.put(3, "70");
- map.put(4, "60");
- map.put(5, "50");
- map.put(6, "40");
- map.put(7, "30");
- map.put(8, "20");
- map.put(9, "10");
- Set<Map.Entry<Integer, String>> entrySet=map.entrySet();
- Iterator<Map.Entry<Integer, String>> it=entrySet.iterator();
- while(it.hasNext()){
- Map.Entry<Integer,String> m =it.next();
- Integer key=m.getKey()+Integer.parseInt(m.getValue());
- String value=m.getValue();
- map1=setMap(key, value);
- }
- System.out.println(map1);
- Set<Integer> keySet1 = map1.keySet();
- HashMap<Integer, String> map2 = new HashMap<Integer, String>();
- for(Integer key:keySet1){
- while (key.intValue() < 50||key.intValue() >150) {
- String value = map1.get(key);
- map2.put(key, value);
-
- break;
- }
-
- }
- System.out.println(map2);
- }
- static Map<Integer, String> map1 = new HashMap<Integer, String>();
- public static Map<Integer,String> setMap(Integer key,String value){
- map1.put(key, value);
-
- return map1;
- }
-
-
-
-
- }
复制代码 |