If anything
is static final
(as in your example), then there is no difference.
However, using the getAnything()
method allows the functionality to be changed without having to refactor code. For instance, logging could be added inside the getAnything()
implementation.
If you implement a getAnything()
method, it would be conventional to change the visibility of anything
from public
to private
.