Sunday, 21 April 2013

What is a Plain Old Java Object or POJO ???

A "POJO" is an ordinary Java Object which does not follow any of the major Java object models, conventions, or frameworks.  

A "POJO" however is bound by the restrictions forced by the Java Language Specification.

Some of these restrictions are ... 

  1. A POJO cannot extend any Class
  2. A POJO cannot implement any Interface
  3. A POJO cannot contain any prespecified annotation 
An example of a simple POJO may be ...

public class POJO {
 
    private String someProperty;
 
    public String getSomeProperty() {
         return someProperty;
    }
 
    public void setSomeProperty(String someProperty) {
        this.someProperty = someProperty;
    }
}

No comments:

Post a Comment