I'm developing an application in Java and in my controller I have a function that generates the random numbers. Example:
In my first column I want you to manage from 0 to 8, until then OK.
In the second column I want to generate 9 to 17, in this case I can not do it because I can not determine which number x
will start, because by default it counts with the beginning of 0.
That is, I want you to generate 0 to 9, then 9 to 17, then 18 to 25, and so on ...
Here is my code below:
public void grupoDeSete(){
Random random = new Random();
/*=====ACTIVITY PLUS=======*/
int generated1_plus = random.nextInt(9);
int generated2_plus = random.nextInt(17 - 9) + 10;
int generated3_plus = random.nextInt(24 - 18) + 20;
/*Grupo de 7 números*/
String sevenGroup = String.valueOf(generated1_plus
+ " - "
+ generated2_plus
+ " - "
+ generated3_plus);
//Resultado
setSecond(sevenGroup);
}
public String getSecond() {
return second;
}
public void setSecond(String second) {
this.second = second;
}
How can I do this?