What is need of beans.we can also create other class to get and set values. Then what is the need of get and set methods.can please explain it using some realtime example.
Joined: Oct 17, 2001
JavaBeans Specification emerged from AWT/SWING frameworks. It defines a standard way of how your encapsualted data should be set or retrieved from an object.
Getter and setter methods were created so that any engine/framework could query for the data dynamically without knowing about the object's methods.
JavaBean specification has also been extended to Java EE. A good example is JSP page using a useBean tag. The bean has getter and setter methods and the jsp container displays/reads the properties and renders the page dynamically for you.
You could refer to petsore web application or any Java Swing sample application to get a better understanding of java beans.