日期:2014-05-20 浏览次数:20746 次
import java.util.Scanner; import java.util.Map; import java.util.HashMap; public class Test { //private Object k ; Map <Object,Double> map = new HashMap<Object,Double> (); //无效 private Double ks ; /** * test map */ public void testmap (){ map.put("diyige", 10.0); map.put("dierge", 100.0); map.put("disange", 1000.0); map.put("disige", 10000.0); map.put("diwuge", 100000.0); //无效 for (int i=map.size()-1;i>0;i--){ for (Map.Entry<Object, Double> entry : map.entrySet() ) { System.out.println(entry.getKey()+">>>>>>>>>>>>>"+entry.getValue()); //无效累加 ks = entry.getValue()+i; } //无效 System.out.println(ks); } //无效 System.out.println(ks); // 无效 } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Test t = new Test (); t.testmap(); } }
import java.util.Map; import java.util.HashMap; public class MapText { // private Object k ; Map<Object, Double> map = new HashMap<Object, Double>(); private Double ks = 0.0; /** * test map */ public void testmap() { map.put("diyige", 10.0); map.put("dierge", 100.0); map.put("disange", 1000.0); map.put("disige", 10000.0); map.put("diwuge", 100000.0); // for (int i = map.size() - 1; i > 0; i--) // { for (Map.Entry<Object, Double> entry : map.entrySet()) { System.out.println(entry.getKey() + ">>>>>>>>>>>>>" + entry.getValue()); ks = entry.getValue() + ks; } System.out.println(ks); // } System.out.println(ks); } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub MapText t = new MapText(); t.testmap(); } }