What Java Beans are, and what can be used for.
Java Beans are Java classes developed following Sun’s Java Code Conventions specifically JavaBeans Spec, in order to be easily used by java developers in IDE tools like Eclipse or Netbeans.
Java Beans, like other Java classes, have properties and methods. Properties always are private, and can be accessed only through methods belonging to the Java Bean. Depending of its nature, Java Beans’ methods can be classified as setters or getters. Setter methods change a property’s value, and getter methods retrieve it.
Getter and setter method’s names must follow JavaBeans naming rules:
- A getter method´s name must be prefixed by get, followed by the property’s name. But if the property is a boolean, the name must be prefixed by is.
- A setter method´s name must be prefixed by set, followed by the property’s name.
- In both cases, the first letter of the property’s name must be uppercase.
- Getter methods must be public, with no arguments, and the return type must match with the property type.
- Setter methods must be public, with an argument that matches with the property type, and the return type must be void.












Leave Your Response