JAVA生成随机字符串
@Test
public void getRandomString() {
String code = "";
Random random = new Random();
for (int i = 0; i < 6; i++) {
int r = random.nextInt(10); //每次随机出一个数字(0-9)
code = code + r; //把每次随机出的数字拼在一起
}
System.out.println(code);
}
最后
以上就是落寞服饰最近收集整理的关于JAVA生成随机字符串的全部内容,更多相关JAVA生成随机字符串内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复