I have the following two classes. Can I say that the first class is POJO and the second is like a Bean class?
1) the POJO class, because it has only the getter and setter method, and all members are declared private
public class POJO { private int id; private String name; public int getId() { return id; } public String getName() { return name; } public void setId() { this.id = id; } public void setName() { this.name = name; } }
2) Bean class - all member variables are private, have getters and setters, and implements the Serializable interface
public class Bean implements java.io.Serializable { private String name; private Integer age; public String getName() { return this.name; } public void setName(String name) { this.name = name; } public Integer getAge() { return this.age; } public void setAge(Integer age) { this.age = age; } }
It also has a no-arg constructor.
java javabeans pojo
Vishnu
source share