java生成6位随机数代码

时间:2020-09-16 21:17:22   收藏:0   阅读:681
//生成6位随机数字
   System.out.println((int)((Math.random()*9+1)*100000));
//生成5位随机数字
   System.out.println((int)((Math.random()*9+1)*10000));
//生成4位随机数字
   System.out.println((int)((Math.random()*9+1)*1000));
//生成3位随机数字
   System.out.println((int)((Math.random()*9+1)*100));
//生成2位随机数字
   System.out.println((int)((Math.random()*9+1)*10));
//生成1位随机数字
   System.out.println((int)((Math.random()*9+1)));

  

原文:https://www.cnblogs.com/jieless/p/13680727.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!