The field is an implementation details, the getter is the API.If you let the caller to use directly the field you can't rely on an implementation changes without to refactor all usages.

I take by example, if you want to change your implementation for a precise field that you want to set it lazy. You want only to read and instanciate it only when it is accessed.If you done a getter at the start point, you can reimplement the getter in order to get your lazy function without any impact of the usage.

If needed, the direct access can be refactored to a getter in a proper interface with about 3 mouse clicks.Until then, I just access directly.(In my own personal little game projects, mind you. When working in teams on larger projects I don't work that way and stick to the generally accepted coding standards for obvious reasons.)

Sometimes I'd wish java would just let me define a field in an interface without needing to implement getters and setters that basically do nothing.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org