生成随机数的工具类(短信验证码)

 1 /*生成count位数的随机数字*/
 2 import java.util.Random;
 3 
 4 public class randomUtil {
 5 
 6     public static String getRandomCode(int count){
 7         StringBuffer s = new StringBuffer();
 8         for (int i = 0; i < count; i++) {
 9              String code = String.valueOf(new Random().nextInt(10));
10              s.append(code);
11 
12         }
13         return s.toString();
14     }
15 }

 

posted @ 2022-03-21 15:33  巴啦啦小花总  阅读(78)  评论(0)    收藏  举报