1 /** 2 * 獲取值的區間 3 * 4 * @param num 值 5 */ 6 public static Map<String, Integer> getNumSection(Integer num) { 7 Map<String, Integer> map = new HashMap(); 8 int length = num.toString().length(); 9 if (length == 1) { //判斷是否為個數 1234567890 10 map.put("maxNum", 0); 11 map.put("minNum", 10); 12 return map; 13 } 14 String count = ""; 15 for (int i = 1; i < length; i++) { 16 count += "0"; 17 } 18 String shou = num.toString().substring(0, 1); 19 int maxNum = Integer.parseInt(shou + count);//最小 20 int minNum = Integer.parseInt(String.valueOf(Integer.parseInt(shou) + 1) + count);//最大 21 map.put("maxNum", maxNum); 22 map.put("minNum", minNum); 23 return map; 24 }