Java生成六位验证码(发短信验证)

public String getRandNum(int charCount) {
        String charValue = "";
        for (int i = 0; i < charCount; i++) {
            char c = (char) (randomInt(0, 10) + '0');
            charValue += String.valueOf(c);
        }
        return charValue;

    }

 public int randomInt(int from, int to) {
        Random r = new Random();
        return from + r.nextInt(to - from);
    }



欢迎关注公众号:Java后端技术全栈