Getters/setters are preferred because they help to abstract the code design, and give you more precise control over how your class is used/accessed.
For example, consider the ArrayList class....
Type: Posts; User: helloworld922
Getters/setters are preferred because they help to abstract the code design, and give you more precise control over how your class is used/accessed.
For example, consider the ArrayList class....
Use of non-final public fields is generally discouraged, use private field with getters/setters instead.
There are a variety of fields at the top which utilize default access restrictions, again...