This is taken from Effective Java by Joshua Bloch-
Item 14 (or Item 16 in the Third Edition): In public classes, use accessor methods, not public fields
// Degenerate classes like this should not be public!
class Point {
public double x;
public double y;
}
Because the data fields of such classes are accessed directly, these classes do not offer the benefits of encapsulation (Item 13).
You can’t change the representation without changing the API
What does the author mean by the last sentence? This statement is used many times in the same item. Please suggest.
The term exported API or API is to be interpreted as suggested by the author in the book
An exported API consists of the API elements that are accessible outside of the package that defines the API.