What is POJO | POJO Class in Java | PLM Developer

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:
  1. POJO class must be public so that it is accessible to all.
  2. Fields or variables defined in the POJO class must be private so that they cannot be accessed directly.
  3. POJO class must have a default no-argument constructor.
  4. 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;
 }
}
    
    

Post a Comment

0 Comments