getRandomInt getRandomString
作者:互联网
import java.util.concurrent.ThreadLocalRandom; private static final String AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; public int getRandomInt() { return ThreadLocalRandom.current().nextInt(10000, 100000); } public String getRandomString(int length) { StringBuilder sb = new StringBuilder(length); for (int i = 0; i < length; i++) { sb.append(AB.charAt(ThreadLocalRandom.current().nextInt(AB.length()))); } return sb.toString(); }
标签:AB,ThreadLocalRandom,getRandomInt,getRandomString,int,length,sb 来源: https://www.cnblogs.com/tonggc1668/p/10918070.html