I have a method that takes in 2 ints method(int ii, int xx). I want to loop through a range of values but I cant think of a way to do it without hard coding each value.
When ii = 21, i want xx = 19 through 9
when ii = 20, i want xx = 18 through 12
so hard coded it would be:
method(21,19)
method(21,18)
...
method(21,10)
method(21,9)
method(20,18)
method(20,17)
...
method(20,13)
method(20,12)
this is what i have so far but it doesnt handle spcific cases like i dont want it to do method(4,19)
for(int ii = 9;ii<21;ii++){
for(int xx = 4;xx<19;xx++){
method(ii,xx);
}
}
As originally suggested by Edd, you’ll want to use a map. I suggest creating a
Rangeclass to represent an integer range for thexxvalues, then you can build a map ofInteger–>Range(ii –> xx):