LoginSignup
2
0

More than 3 years have passed since last update.

Java random, 処理いろいろ

Last updated at Posted at 2019-07-04
  • 単純な乱数
new Random().nextXxx();
new Random().nextXxx(10);
  • 重複なし乱数リスト
new Random().ints(0, Integer.MAX_VALUE)
    .distinct()
    .limit(10)
    .boxed()
    .collect(Collectors.toList())
  • リスト乱数取得
list.get(random.nextInt(list.size()));
2
0
6

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0