随机3位ascii码(Random 3-bit ASCII code)

1. 利用大小写字母和数字生成范围内不重复的3位字符串

 1   public void getTargetNo() {
 2         final String WORD = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
 3         final int BASE = WORD.length();
 4         int increaseId = 0;// 增长的序列
 5         int div = increaseId;
 6         StringBuffer sb = new StringBuffer();
 7         while (div > 0) {
 8             int surplus = div % BASE;
 9             div = div / BASE;
10             sb.append(WORD.charAt(surplus));
11         }
12         String target = sb.append("000").reverse().toString();
13         target = target.substring(target.length() - 3, target.length());
14         System.out.println(target);
15     }
————————

1. Use upper and lower case letters and numbers to generate a 3-bit string that is not repeated in the range

 1   public void getTargetNo() {
 2         final String WORD = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
 3         final int BASE = WORD.length();
 4         int increaseId = 0;// 增长的序列
 5         int div = increaseId;
 6         StringBuffer sb = new StringBuffer();
 7         while (div > 0) {
 8             int surplus = div % BASE;
 9             div = div / BASE;
10             sb.append(WORD.charAt(surplus));
11         }
12         String target = sb.append("000").reverse().toString();
13         target = target.substring(target.length() - 3, target.length());
14         System.out.println(target);
15     }