Since you are using array, the size of array is determined during compilation. Thus if your intention is to check whether current array’s index has reached the last array element, you may use the following condtion (possibly in a loop) to check whether your current array index is the last element. If it is true, then it has reached the last element of your array.
int candy = new int; //Array size is 10 //first array: Index 0, last array index: 9. for (int x=0; x < candy.length; x++) if (x == candy.length - 1) //Reached last element of array
You can check the size of the array by using:
You check whether it is last element by using:
if (currentIndex == candy.length - 1) //Where candy is your array
Make sure you are using double equal
== for comparison.
= is for assignment.