What is the difference between pojo and poji




















Hi friends, as we all know that java bean is a fully encapsulated classes because all the variables of bean class are defined as private. Order Mismatch: If there are more variables so at the time of method calling the order of variable must be follow. But usually not possible to remember the order of all variables. Which usually cause exception at run time. So lets see all in detail about bean class and what is difference between bean class and Pojo classes.

Bean Class:- Bean class is a special java class, that follow some special rules. You are commenting using your WordPress. You are commenting using your Google account.

You are commenting using your Twitter account. You are commenting using your Facebook account. Notify me of new comments via email. Notify me of new posts via email.

Skip to content. Important points:- Java Beans and Pojo both are not going to be main component of application. They are helper components. Java Bean and Pojo objects are used, when we want to send huge data industry standard is more than three variables through method calling.

Problem without JavaBeans and PoJO:- Order Mismatch: If there are more variables so at the time of method calling the order of variable must be follow. Getters and setters provide the complete restriction on fields. Any object can set it 0. But by using the setter method, you have control. You can have a condition in your setter method. Similarly, for getter method if you want that if your age is 0 then it should return null, you can achieve this by using the getter method as in the following example:.

It is a special POJO which have some restrictions. It provides complete control on members. It can implement Serializable interface. It should implement serializable interface. Fields can be accessed by their names.

Fields are accessed only by getters and setters. Fields can have any visibility. Fields have only private visibility. It must have a no-arg constructor. Conclusion POJO classes and Beans both are used to define java objects to increase their readability and reusability. This article is contributed by Vishal Garg. If you like GeeksforGeeks and would like to contribute, you can also write an article using write. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. Skip to content.

Change Language. Related Articles. Table of Contents. Save Article. Improve Article. Like Article. String name;. Next Serialization and Deserialization in Java with Example. Recommended Articles. Article Contributed By :. Easy Normal Medium Hard Expert.



0コメント

  • 1000 / 1000