Answer the question
In order to leave comments, you need to log in
How to generate a random number with different digits?
Hello. How to generate a random number with different digits in java? Thanks in advance.
Answer the question
In order to leave comments, you need to log in
Use Random to get a random number
Random random = new Random();
int result = random.nextInt(1000); // Генерация случайного числа от 0 до 1000
System.out.println(result);
result = 9 + random.nextInt(9) // Генерация случайного 9 значного числа, где каждая цифра можешь иметь значение от 0 до 9
System.out.println(result);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question