I\'m not even sure if this code will do anything even if it works, but I don\'t know what to do to get rid of the \"Local variables referenced from an inner class must be final
You haven't shown all the code, but I suspect that adding:
final int i0 = i;
inside your loop and using i0
instead of i
as the index for your arrays should fix the error.
Alternatively, as commented by @James_D, you can also add Sprite sprite = fireballRight[i];
before the anonymous class and use sprite
inside the handle
method.
Note that the final
modifier is optional in this case with Java 8+.