日期:2014-05-19 浏览次数:20704 次
public static int random() { TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>(); map.put(0, 0); map.put(7, 1); int ran = (int)(System.currentTimeMillis()%10); return map.lowerEntry(ran).getValue().intValue(); } if (random() == 0) { System.out.println("do A"); } else { System.out.println("do B"); }