Array Index Out of Bounds error on Array List

How about this:

you first create a global variable like this:

String[] originalList = {"apple", "orange", "grape", "banana", "lemon"};

Then you add a function that duplicate your list:

String[] duplicateOriginalList() {
  String[] result = new String[originalList.length];
  for(int i = 0; i < originalList.length; i++) {
    result[i] = originalList[i];
  }
  return result;
}

All you have to do then is add the following line in your setup() function and just after your gameOver() call.

list = duplicateOriginalList();

Probably not the best and the most efficient way to do it but it is quick to implement and you don’t have to redo all of your code :slight_smile: