diff --git a/guide/english/java/pojo/index.md b/guide/english/java/pojo/index.md index a221320075..524e1d24c6 100644 --- a/guide/english/java/pojo/index.md +++ b/guide/english/java/pojo/index.md @@ -27,6 +27,31 @@ public class Bar implements javax.ejb.EntityBean { } ``` +4. For any class field which is marked as private it must have getter and setter methods alongside it. Also it must have EMPTY constructor if custom constructor declared. +``` +public class Car { + + private int gear; + + // default constructor + public Car() { } + + // custom constructor + public Car(int car){ + this.car = car; + } + + public int getGear() { + return this.gear; + } + + public void setGear(int gear){ + this.gear = gear; + } + +} +``` + Therefore a Java Object qualifies as a POJO only when it is free from the above modifications. It therefore follows that a POJO is not 'bound by any restrictions' other those prescribed by the formal Java language specification. POJO is usually used to describe a class that doesn't need to be a subclass of anything, or implement specific interfaces, or follow a specific pattern. It has properties, getters and setters for respective properties. It may also override Object.toString() and Object.equals().