Bean Internals  «Prev 

Implementing Accessor Methods

Just as with single-valued (non-indexed) properties, you are free to implement any of these accessor methods you choose.
For example, you may not want to allow direct access to the entire array of properties, in which case you would not implement the second pair of accessor methods.
Optionally, you could make an indexed property read-only by eliminating both setter methods.

Persistent values should be accessed through methods called getXxx and setXxx.

For example, if your Car class stores the current number of passengers, you might have methods named getNumPassengers (which takes no arguments and returns an int) and setNumPassengers (which takes an int and has a void return type). In such a case, the Car class is said to have a property named numPassengers (notice the lowercase n in the property name, but the uppercase N in the method names). If the class has a getXxx method but no corresponding setXxx, the class is said to have a read-only property named xxx.
The one exception to this naming convention is with boolean properties: they are permitted to use a method called isXxx to look up their values. So, for example, your Car class might have methods called isLeased (which takes no arguments and returns a boolean) and setLeased (which takes a boolean and has a void return type), and would be said to have a boolean property named leased (again, notice the lowercase leading letter in the property name).