Java Bean is a Java class that follows below conventions.
a. The class must have a public default constructor.
b. Appropriate properties must have public getter and setter methods
c. The class should be serializable. This allows applications to reliably save, store, and restore the bean's state in a manner independent of the VM and of the platform.)
Whereas POJO stands for Plain Old Java Object, it is just a Java Object. All Java Beans are POJOs but all POJOs are not Java Beans.
Example of Bean.
Point.java
package com.sample.app.beans;
import java.io.Serializable;
public class Point implements Serializable {
private int x;
private int y;
public Point() {
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
}
You may
like
No comments:
Post a Comment