POJO stands for Plain Old Java Object. POJO class is a bind of
private fields and public getter and setter methods. POJO classes
mainly used for readability and re-usability of code.
Features of POJO class:
- POJO class must be public so that it is accessible to all.
- Fields or variables defined in the POJO class must be private so that they cannot be accessed directly.
- POJO class must have a default no-argument constructor.
- Getter and Setter methods in the class should be public.
POJO Class Example:
public class Employee {
private String id;
private String name;
public Employee (String id, String name) {
this.id = id;
this.name = name;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
}
1 Comments
This comment has been removed by a blog administrator.
ReplyDelete