What is a JavaBean exactly?

后端 未结 19 1662
清酒与你
清酒与你 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:41

    A Java Bean is a java class [conceptual] that should follow following conventions:

    1. It should have a no-arg constructor.
    2. It should be Serializable.
    3. It should provide methods to set and get the values of the properties, known as getter and setter methods.

    It is a reusable software component. It can encapsulate many object into one object so that same object can be accessed from multiples places and is a step towards easy maintenance of code.

提交回复
热议问题