I have a small question about the 'final' keyword. I just now used it to solve a certain problem, but I'm not sure how it works (Eclipse told me to :(think):).
It's the following:
In a constructor of a class, I loop through an enum with this: for(Direction dir : Direction.getValues()).
In this loop, I create an instance of some other class for each direction. This instance overrides a method
from its class, and uses the 'dir' value in this method.
Now I've had to use the final modifier on 'dir'. But I don't really understand why. To be completely honest, my instinct told me what I was trying to do the way I was doing it was logically impossible. That's why I was completely stumped when the 'final' keyword actually solved it. Is this because the value is an enum?