difference between pojo class and a java bean in java? [duplicate]
difference between pojo class and a java bean in java?
http://www.theserverside.com/discussions/thread.tss?thread_id=35146
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){...};
Additionally, true JavaBeans must implement Serializable and have a no-argument constructor. POJOs don't have these restrictions.
A Java Bean requires setters and getters and serialization.
a POJO is a "Plain Old Java Object" that doesn't have any specific requirements.
Personally I hate seeing Beans referred to as POJOs, we already have a very specific word for Java Bean. The tendancy to mix them up probably stems from the fact that many new programmers put setters and getters on every java object anyway so they tend to look identical.
精彩评论