Programming difference between POJO and Bean

前端 未结 2 1454
深忆病人
深忆病人 2021-01-03 11:16

I have the following two classes. Can I say the first one is a POJO class and the second one as a Bean class?

1) POJO class, since it has only getter and setter meth

相关标签:
2条回答
  • 2021-01-03 11:41

    the JavaBean class must implement either Serializable or Externalizable, must have a no-arg constructor,all JavaBean properties must public setter and getter methods (as appropriate) all JavaBean instance variables should be private

    0 讨论(0)
  • 2021-01-03 11:43

    Only difference is bean can be serialized.

    From Java docs - http://docs.oracle.com/javase/7/docs/api/java/io/Serializable.html

    Serializability of a class is enabled by the class implementing the java.io.Serializable interface. Classes that do not implement this interface will not have any of their state serialized or deserialized. All subtypes of a serializable class are themselves serializable. The serialization interface has no methods or fields and serves only to identify the semantics of being serializable.

    0 讨论(0)
提交回复
热议问题