Menu

Post image 1
Post image 2
Post image 3
1 / 3
0

What is POJO in Java?

DEV Community·Divya Divya·21 days ago
#XfiUjxbH
Reading 0:00
15s threshold

POJO(Plain Old Java Object: A Java Programming POJO (Plain Old Java Object) is a simple normal Java class that is not connected to any special framework or restriction.Is not dependent on frameworks like EJB. It does not need special classes, interfaces, or dependencies. A POJO usually contains fields, constructors, getters, setters, and normal methods. Why is POJO? POJO is used to create simple Java classes. It makes code easy to write and understand. It helps to store object data like name, age, id, etc. It improves code reusability. It is easy to test and maintain. Example: class Student { private String name ; private int age ; // Constructor Student ( String name , int age ) { this . name = name ; this . age = age ; } // Getter public String getName () { return name ; } // Setter public void setName ( String name ) { this . name = name ; } public static void main ( String [] args ) { Student s1 = new Student ( "Divya" , 20 ); System . out . println ( s1 .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More