开发者

difference between pojo class and a java bean in java? [duplicate]

This question alr开发者_如何学JAVAeady has answers here: What is the difference between a JavaBean and a POJO? (10 answers) Closed 4 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜