随机数


随机数

Random 类,其中内置了生成随机数的方法

Random random = new Random();
sout(random.nextInt(100));  //生成一个0-100的随机整数
sout(random.nextInt(30,40));//30-40的随机数

Author: havenochoice
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source havenochoice !
评论
  TOC