I have several ArrayLists with certain values stored in them and I want to check my program to check the above operators. I have tried looking at the ArrayList api and couldn't find anything that could really do what I wanted.
Ultimately, I'm trying to code something that given user's input, it'll check
X * Y = Z
X / Y = Z
X - Y = Z
X + Y = Z
but the problem is that I'm confused on how to make it check for all the different combinations since the .get() only iterates from 0-max size.
Also, I know that .get() returns an Object, which I have tried to convert to an int and have it do the above but, again, it would only check the combinations when they were all in the same index.
*edit*
I'm also confused on how to iterate through 3 different ArrayLists
*edit*
I just tried using the Iterator class but I'd rather use the for loop if I could figure out a way to do the above. The below doesn't work though, it'll loop infinitely with no increasing count. It's just a general idea of what I'm trying to do.
Iterator x = list[k1].iterator(); Iterator y = list[k2].iterator(); Iterator z = list[k3].iterator(); int count = 0; int r = Integer.parseInt((String)x.next()); int s = Integer.parseInt((String)y.next()); int t = Integer.parseInt((String)z.next()); while(x.hasNext() && y.hasNext() && z.hasNext()) { if(r + s == t) { count++; } if(r - s == t) { count++; } if(r * s == t) { count++; } if(r / s == t) { count++; } }