This question already has an answer here:
I am calling a method outside of main to try and get a random integer between two integers. I am supposed to initialize the method in main by calling it and giving the arguments, the arguments being the two numbers that are the maximum and minimum. Some parameters are that the random number has to be returned, and that the maximum number can not be a random number. For example, between 6 and 8, 6 and 7 can be a random number, but eight can not be. Can someone guide me into solving this problem?
public static void main(String[] args) {
System.out.println(randomIntBetween(6,8));
}
public static int randomIntBetween(int num1, int num2) {
//code to find random number here
}
Aucun commentaire:
Enregistrer un commentaire