What is a JavaBean exactly?

后端 未结 19 1655
清酒与你
清酒与你 2020-11-22 01:55

I understood, I think, that a \"Bean\" is a Java class with properties and getters/setters. As much as I understand, it is the equivalent of a C struct. Is that true?

<
19条回答
  •  难免孤独
    2020-11-22 02:20

    JavaBeans are Java classes which adhere to an extremely simple coding convention. All you have to do is to

    1. implement java.io.Serializable interface - to save the state of an object
    2. use a public empty argument constructor - to instantiate the object
    3. provide public getter/setter methods - to get and set the values of private variables (properties ).

提交回复
热议问题