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.
Answer from Ankur Singhal on Stack OverflowPojo
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.
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.
Can pojo classes have some logic inside?
Not null fields in a POJO class.
Having the same POJO in multiple microservices
How to convert json string to pojo if json response starts with [] instead of {} ??
How do POJO classes work with Hibernate?
Is a POJO always serializable?
How is POJO used in Spring Boot?
Videos
I am trying to build a text adventure in java. I have something running already, but now I realized that I want to store some configuration in json/yaml (I did not decided yet). Then I'll use something like Jackson for deserializing. Now, as far as I know, POJO classes must have only variables, empty constructor, getters and setters. But I have some classes that I'd like to use for deserializing that contains other methods, for example the Player class has methods for moving, attacking and so on. Does this creates errors with JSON parsing? Is this a bad practice in some way?
Side question, I always thought that POJO classes kinda "violates" encapsulation principle, because from my understanding encapsulation states that an object contains data and behavior. Am I missing something?