Java写生成一个由数字和大小写字母随机组合而成的字符串,长度是10到18之间的随机整数

如题所述

public class Randomcode {
private static String baseChars = "qwertyuiopasdfghjklzxcvbnm0123456789";

public static String getChar(int len){
String chars = "";
for(int i=0;i<len;i++){
int baseIndex = (int)(Math.random() * baseChars.length()) + 1;
chars += baseChars.charAt(baseIndex);
}
return chars.toUpperCase();
}
}

 何为随机整数?

追问

大于10小于18的任意整数
看到你写的我也知道怎么取这个数了

温馨提示:答案为网友推荐,仅供参考
相似回答