How do you use random for a limit of numbers in JAVA

in this case I'll say I wanna make random digits within 45 to 52 explain to me what I can do! thnx anyway
No description
10 Replies
JavaBot
JavaBot14mo ago
This post has been reserved for your question.
Hey @OMIDD! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Defective
Defective14mo ago
So basically you want to get a random number between x nad y?
MoonSouhayl
MoonSouhayl14mo ago
whats the purpose of the visual studio code image ? + thats question is a google question u can just type exactly that, add java at the end and u will get a faster respond
OMIDD
OMIDDOP14mo ago
yes nothing can you help me ?
MoonSouhayl
MoonSouhayl14mo ago
No description
No description
Defective
Defective14mo ago
+ If you are using Java 8 or later you can use ThreadLocalRandom.current().nextInt(min, max + 1); where min in your case would be 45 and max - 52
OMIDD
OMIDDOP14mo ago
hmm thnx
Defective
Defective14mo ago
If your question is answered you can close this post
fertiz
fertiz14mo ago
as I remember Random class also supports that, but might be newer versions
JavaBot
JavaBot14mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?