Allowed, but, if you are going to use the enum in multithreaded environment, please do not forget that although Java enum, effectively a lazy-initialized singleton,
is guarded by Java during the lazy initialization
(meaning here that no any other thread could access the enum until the initializing thread has not completed the initialization),
it is not anyhow guarded against a concurrent use of the setter.
So, in the OP's case of simple setter it is enough to declare the mutable field as volatile
(remove final
of course):
volatile int letter;
In more complex cases like increments or others (highly unlikely with enums, but ... who knows, enum setter is itself an exotic thing) other concurrency weaponry like Atomic
s, synchronized
blocks, Lock
s might be needed.
Also, there is a discussion on enum thread safety