The other reason why to prefer methods can be found in the Java Virtual
Machine specification. It is allowed to move a method from a class
to one of its superclasses and still remain binary compatible. So a method
initially introduced as Dimension javax.swing.JComponent.getPreferredSize(Dimension d) can
be deleted in new version and moved to
Dimension java.awt.Component.getPreferredSize(Dimension d) as
the JComponent is a subclass of Component (this
really happened in JDK 1.2). Such operation is not allowed for fields. Once
a field is defined in a class, it has to stay there forever in order to
keep binary compatibility. That is another reason why it is better to keep fields
private.