随机数和随机字母

Posted yrjns

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了随机数和随机字母相关的知识,希望对你有一定的参考价值。

随机数

Random random = new Random();
Float i = random.nextFloat();
System.out.println((int)(i*1000000));// 815214
Random random = new Random();//默认构造方法
Random random = new Random(1000);//指定种子数字 int i = random.nextInt(100); System.out.println(i);// 87

 

随机字母

(char)(int)(Math.random()*26+97)    // 小写

(char)(int)(Math.random()*26+65)    // 大写

 

以上是关于随机数和随机字母的主要内容,如果未能解决你的问题,请参考以下文章