POJO(Plain Old Java Object:
A Java Programming POJO (Plain Old Java Object) is a simple normal Java class that is not connected to any special framework or restriction.Is not dependent on frameworks like EJB.
It does not need special classes, interfaces, or dependencies.
A POJO usually contains fields, constructors, getters, setters, and normal methods.
Why is POJO?
- POJO is used to create simple Java classes.
- It makes code easy to write and understand.
- It helps to store object data like name, age, id, etc.
- It improves code reusability.
- It is easy to test and maintain.
Example:
class Student {
private String name;
private int age;
// Constructor
Student(String name, int age) {
this.name = name;
this.age = age;
}
// Getter
public String getName() {
return name;
}
// Setter
public void setName(String name) {
this.name = name;
}
public static void main(String[] args) {
Student s1 = new Student("Divya", 20);
System.out.println(s1.getName());
}
}
Output

Top comments (0)