I
I
Ivan Kolchev2017-04-15 21:14:39
Java
Ivan Kolchev, 2017-04-15 21:14:39

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

1 answer(s)
V
Vorh, 2017-04-15
@Vorh

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 question

Ask a Question

731 491 924 answers to any question