Java随机生成6位数字

生成6位随机数(不会是5位或者7位,仅只有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));
Last modification:December 14th, 2017 at 11:23 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment