I have an int n which chooses a random number. Each time I save n in arraylist array. Now I want to compare that if int n is equal to two last random numbers. For example if we have 2 - 3 - 5- 3 , it should choose 3 as a repeated int. Should I compare it them like this?
if(n == array.size()-2) {
}
It doesn’t work like this. Where is the problem?
1 Answer