0
0

More than 3 years have passed since last update.

java(乱数)

Posted at

乱数を発生させる

int a = new java.util.Random().nextInt();

①に1以上の整数を指定すると0以上かつ①で指定した数未満のランダム整数がaに代入
例:10を代入するとaに0〜9のいずれかが代入

キーボードから1行の入力を受け取る命令

文字列の入力を受け付ける

String a = new java.util.Scanner(System.in).nextLine();

整数の入力を受け付ける

int a = new java.util.Scanner(System.in).nextInt();
0
0
0

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
0
0