This question has already been answered:
Made a program of random number generator. I wanted to make sure that the user himself could set up the upper threshold of the number. But how to do it? (example):
System.out.println("Введи новое число"); Scanner userNewNum = new Scanner(System.in); int x = userNewNum.nextInt(); Random randNum = new Random(); int randNumVar = randNum.nextInt(1 - x); I know it doesn't work. What is the right way then?