java (random number)

Generate random numbers

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

If an integer of 1 or more is specified in ①, a random integer of 0 or more and less than the number specified in ① is assigned to a. Example: Substituting 10 causes any of 0 to 9 to be substituted for a

Command to receive one line of input from the keyboard

** Accepts character string input **

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

** Accepts integer input **

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

Recommended Posts

java (random number)
[Java] Random number generation method (Random)
[Java] Random method
C # (random number) memo
Random number creation (Math.random ();)
Java random, various processing
[java] Decimal number → n-ary number n-ary number → decimal number
Java
Java
Java learning (0)
[Java] array
Java protected
[Java] Module
Java array
Studying Java ―― 9
Java scratch scratch
Java tips, tips
Java methods
Java method
java (constructor)
Java array
[Java] ArrayDeque
java (override)
java (method)
Java Day 2018
Java string
java (array)
Java static
Java serialization
java beginner 4
[Personal memo] How to interact with a random number generator in Java
JAVA paid
Studying Java ―― 4
Java (set)
java shellsort
[Java] compareTo
Studying Java -5
java reflexes
java (interface)
Java memorandum
☾ Java / Collection
Java array
Studying Java ―― 1
[Java] Array
[Java] Polymorphism
Studying Java # 0
Java review
java framework
Java features
[Java] Inheritance
FastScanner Java
Java features
java beginner 3
Java memo
java (encapsulation)
Java inheritance
[Java] Overload
Java basics
Decompile Java
[Java] Annotation
java notes