JavaBeans Conventions


JavaBeans are classes that encapsulate many objects into a single object (the bean). They are serializable, have a zero-argument constructor, and allow access to properties using getter and setter methods.

Source Code

public class EmployeeBean implements java.io.Serializable {
    private int id;
    private String name;

    public EmployeeBean() { }

    public int getId() { return id; }
    public void setId(int id) { this.id = id; }

    public String getName() { return name; }
    public void setName(String name) { this.name = name; }
}

Adhering to the JavaBeans conventions allows your classes to be easily serialized, inspected, and manipulated by various tools and frameworks.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments