Can any one explain me what is Pojo in java?

9.3k views Asked by At

I started learning Spring Framework, the term pojo is coming so many times, and I am confused what the difference between a normal (Animal a1=new Animal()) object and a pojo object ...

4

There are 4 answers

0
Ankur Singhal On

Pojo

Plain Old Java Object

is a Java object not bound by any restriction other than those forced by the Java Language Specification. I.e., a POJO should not have to

Extend prespecified classes

Implement prespecified interface

Contain prespecified annotations

Basically a class with attributes and it's getters and setters.

2
Sonu Gupta On
  • POJO, or Plain Old Java Object, is a normal Java object class (that is, not a JavaBean, EntityBean etc.)
  • It does not serve any other special role nor does it implement any special interfaces of any of the Java frameworks.
  • This term was coined by Martin Fowler, Rebbecca Parsons and Josh MacKenzie who believed that by creating the acronym POJO, such objects would have a "fancy name", thereby convincing people that they were worthy of use.
0
Shailesh Yadav On

In simple terms There is no difference between a normal (Animal a1=new Animal()) object and a pojo object except that Animal class could have other methods and could extend or implement other class or interface respectively but POJO class only has getter, setter method and does not extend or implement prespecified classes or interfaces.

POJO(Plain Old Java Object) is nothing but a simple java class which has attributes(Variables) and their getter setter methods to manage pojo objects.

0
venkata krishna On

yes,it is a normal java class u can create variables and implement getter and setters methods and use it.