As part of my Java study, I needed a random number to create the answer when creating "Hit & Blow", so I will output a little of the knowledge I gained at that time.
The "Hit & Blow" I created needed a number from 0 to 9, so I used the ** "Math class" ** below.
qiita.java
Math.random();
By using ** "Math class" ** in this way, you can get double type random numbers from 0.0 to less than 1.0.
For example
qiita.java
(int)(Math.random() * 10);
Random numbers from 0 to 9 can be obtained. (By the way, the first (int) is cast to int)
What did you think.
In this article, I introduced how to get random numbers by using ** "Math class" **.
Of course, there are other ways to get random numbers, so if you want to know more, please check it out.
Also, since I am still a beginner, I would appreciate it if you could point out any information due to incorrect notation or recognition in this article.