A property is just a combination of a backing field and its accessors. It could be a backing field with both a getter and a setter or a backing field with only one of them. Properties can be defined at the top level (directly inside the file) or as a member (for example, inside the class or interface).

In general, it is advisable to define properties (private fields with getters/setters) instead of accessing public fields directly (according to Effective Java, by Joshua Bloch, item 14: in public classes, use accessor methods, not public fields).

Java getter and setter conventions for private fields Getter: A parameterless method with a name that corresponds to the property name and a get prefix (for a Boolean property there might ...

Get Android Development with Kotlin now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.