待办分表处理方式

2019-09-29  本文已影响0人  花无重日人未红

根据人员的散列码选择需要存放的表


public static void main(String[] args) {

String personId = "901075";

personId = CommonUtil.trim(personId);

int hashCode = personId.hashCode();// 通过散列码的方式存储对象地址信息,如果两个对象eqauls比较相同,那么它们的hashCode值一定要相同;

int num = Math.abs(hashCode % 10);// Math.abs获取绝对值,%取余(取模)

 System.out.println(hashCode + "," + num);  }

需要全部扫描待办表时,将表名称拼装成数组


public static String[] getTableSetNos() {

String[] tableSetNos = new String[10];

for (int i = 0; i < 10; i++) {

String tableSetNo = Integer.toString(i);

while (tableSetNo.length() < 10) {

tableSetNo = "0" + tableSetNo;

}

tableSetNos[i] = tableSetNo;

}

return tableSetNos;

}

将表名称的后两位数字部分存放到id的前两位,根据id直接定位

上一篇 下一篇

猜你喜欢

热点阅读