In the previous example, the Person class defined properties name and age, of types String and int respectively. The properties were defined by the fact that the class defined methods getName, setName, getAge, and setAge.
The JavaBeans specification details how to define properties; however, the basic rules are as follows:
To define a configurable property, a class defines a
getXmethod that takes no arguments and returns a value, and asetXmethod that takes one argument and returnsvoid. The type returned by thegetXmethod must be the exact same type as the type taken as an argument by thesetXmethod, and can be any Java type. Both thegetXandsetXmethods must be declaredpublic.One exception applies: the
getXmethod for a Boolean property can be replaced byisX. For example, the Boolean propertyrunningcan be defined by the methodgetRunning()orisRunning().The property name is formed by removing
getorsetfrom the method name and changing the first letter of the remaining string to lower case. For example, the methodgetFirstName()defines a property calledfirstName.One exception applies: if the first two letters of the remaining string are both capitalized, no letters are changed to lower case. For example, the method
getURL()defines a property calledURL.
Property names are case-sensitive. Thus, the entry Age=20 does not set the property Person.age.

