java 获取传入值的区间
作者:互联网
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 }
标签:map,java,传入,int,获取,minNum,num,put,Integer 来源: https://www.cnblogs.com/zc-chuang/p/13344295.html