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 ...
-
2From first result in google : *POJO, or Plain Old Java Object, is a normal Java object class (that is, not a JavaBean, EntityBean etc.) and does not serve any other special role nor does it implement any special interfaces of any of the Java frameworks.*. Basically it is just a *simple / ordinary object* in java. – TheLostMind Jun 09 '15 at 06:17
-
Wkipedia can do it: http://en.wikipedia.org/wiki/Plain_Old_Java_Object – Jens Jun 09 '15 at 06:17
-
After looking at the different responses to this question and doing a bit of Google research, I'm convinced that there is are multiple definitions of POJO, and that some of the definitions seems contradictory. I'm afraid you'll have to figure out what the author means based on context. But at least you have a few different possibilities now to choose from. – ajb Jun 09 '15 at 06:45
4 Answers
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.

- 26,012
- 16
- 82
- 116
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.

- 1,061
- 1
- 15
- 30
- 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.

- 347
- 3
- 16
-
Interesting... you say a POJO is a "normal" object class, i.e. not a JavaBean, but the Wikipedia article says a JavaBean is a particular type of POJO, which is contradictory. Actually, the Wikipedia article says that POJO's don't have any restrictions other than what the Java language puts on them, but then a JavaBean does have some restrictions--it has to have a no-arg constructor, it has to have getters and setters with specific names, etc. .... So now I'm wondering if anyone really knows what a POJO is. But it's a cool name, anyway. – ajb Jun 09 '15 at 06:34
-
You are right @ajb. Wikipedia also says this. "We wondered why people were so against using regular objects in their systems and concluded that it was because simple objects lacked a fancy name. So we gave them one, and it's caught on very nicely." please comment if you can give some more suggestion. Thanks. – Sonu Gupta Jun 09 '15 at 06:44
yes,it is a normal java class u can create variables and implement getter and setters methods and use it.

- 19
- 2