Java code that will generate a random number between 1 and 100 without repeating the random numbers.
It’s for my exercise at school
Java code that will generate a random number between 1 and 100 without repeating the random numbers.
It’s for my exercise at school
@RodgersKhosa Replit ask is not for getting answers for your school projects. If you need help, members can help you but include that this is a school project when making the post
He said it was for school in his post…?
Yes they did. Even if they did not this is the kind of question that would be asked in school
so I’m guessing that’s why my answer was removed
Yes that was why it was removed
Hello @RodgersKhosa welcome to the community!
Like it was said before, we are not to give you direct answers but to help you with your growth!
That being said, we can give you a few tips!
random
class from java.util
to generate random numbers and the ArrayList
class to store the unique numbers!contains
method). (Remember that we need unique numbers, so we must check if the generated number is already in the list. If the number is already in the list, it’s not unique, so we shouldn’t add it to the list.)add
method of the ArrayList class to add elements to the list.This will give you a starting point to produce your code. Don’t forget that you need to print the numbers!
When did that get there?
Okay, what class in java allows you to create an “array” of varibles with no repeating values.