JAVA获取六位随机数

public static String getSixNum() {
  String str = "0123456789";
  StringBuilder sb = new StringBuilder(4);
  for (int i = 0; i < 6; i++) {
   char ch = str.charAt(new Random().nextInt(str.length()));
   sb.append(ch);
  }
  return sb.toString();
 }

  

posted @ 2019-05-03 15:24  yvioo  阅读(2469)  评论(0编辑  收藏  举报