Places where JavaBeans are used?

后端 未结 4 1277
面向向阳花
面向向阳花 2020-11-22 13:45

What is a JavaBean and why do I need it? Since I can create all apps with the class and interface structure? Why do I need beans? And can you give me some examples where bea

4条回答
  •  不知归路
    2020-11-22 14:23

    A bean is nothing much, really. For a class to be a "bean", all it requires is:

    • to have a public, no argument constructor
    • to be serializable (to implement the Serializable interface, either directly or through one of its super classes).

    To that, you can add getters and setters for properties of the class that conform to a specific naming convention if you want the fields to be discoverable in certain circumstances (e.g. making that class some object you can drag and drop from a visual editor in your IDE, for example).

    You can find more directly from Sun here.

提交回复
热议问题