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; 
app

    }dom

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

相關文章
相關標籤/搜索