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.
This method for defining properties is outlined in detail in the JavaBeans specification. However, the basic rules are as follows:
To define a configurable property, your class should define 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 may be any Java type. Both thegetXandsetXmethods must be declaredpublic.An exception to the above rule is that the
getXmethod for a Boolean property may be replaced byisX. For example,getRunningandisRunningcan both define therunningproperty, but only ifrunningis a Boolean property.The name of the property is formed by taking the part of the method name following the
getorsetand changing the first letter to lower case. For example, the methodgetFirstName()would define a property calledfirstName.An exception to the above rule is if the first two letters following the
getorsetare both capitalized. In such a case, no letters are changed to lower case. For example, thegetURLmethod defines a property calledURL.
It is important to pay attention to the capitalization, because property names are case-sensitive. For example, an entry Age=20 would not set the age property of the Person object.

