java生成6位数字短信验证码
解决方法:
String symbols = "0123456789"; // 数字
Random random = new SecureRandom();
// 如果需要4位,那 new char[4] 即可,其他位数同理可得
char[] nonceChars = new char[6];
for (int i = 0; i < nonceChars.length; i++) {
nonceChars[i] = symbols.charAt(random.nextInt(symbols.length()));
}
String code=new String(nonceChars);
向大家推荐《Activiti工作流实战教程》:https://xiaozhuanlan.com/activiti