O'Reilly logo

JavaBeans Unleashed by Rick Leinecker, Dr. Donald Doherty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Bean Properties

Bean properties are equivalent to the data fields in a Java object, except that bean properties must be declared as private data fields, and they must be accessible through special public methods known as accessor methods. Properties are discrete chunks of named data that are like attributes of physical objects such as color, temperature, and size. Add a property to a bean by adding a private data field and at least one accessor method. As the creator, you have to decide if a private data field is what you want. If you make it private, you give up some of the benefits of inheritance. This is not the case if you make it a protected property.

Private Data Fields

Use descriptive variable names for your property's private data field. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required