0

Is java beanand java POJO same thing or there are differences?

Lrrr
  • 4,755
  • 5
  • 41
  • 63
galeb
  • 155
  • 2
  • 8

1 Answers1

2

All JavaBeans are POJOs but not all POJOs are JavaBeans.

A JavaBean is a Java object that satisfies certain programming conventions:
the JavaBean class must implement either Serializable or Externalizable
the JavaBean class must have a no-arg constructor
all JavaBean properties must public setter and getter methods (as appropriate)
all JavaBean instance variables should be private

SonalPM
  • 1,317
  • 8
  • 17
  • 2
    very good answer. In addition to what you have said, some Java extension operations such as persistence and graphics favour JavaBeans over POJOs – ha9u63a7 Oct 28 '14 at 09:07
  • 4
    100% identical with [this answer](http://stackoverflow.com/a/24886660/2817802) did you just copy it? – Baby Oct 28 '14 at 09:08
  • @TheQuickBrownFox: Nop.. This is what that is taught when You start learning Java........... ...... ............. The Java-Beanness of a POJO is that it's public attributes are all accessed via getters and setters that conform to the JavaBeans conventions. e.g. private String foo; public String getFoo(){...} public void setFoo(String foo){...}; – SonalPM Oct 28 '14 at 09:15
  • the resemblance is uncanny – Sergio Oct 28 '14 at 10:25