java bean规范的来由

JavaBean

A JavaBean is a Java class that should follow the following conventions:

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

Serializable序列化的含义:

That is nothing but a "marker interface"  that tells Java that the implementing class consents to "serialization" -- a process that converts an instance into a stream of bytes.

Those bytes can be stored in files, sent over a network connection, etc, and have enough info to allow a JVM to reconstruct the object later -- possibly in a different instance

of the application, or even on a whole other machine!

Of course, in order to do that, the class has to abide by certain limitations. Chief among them is that all instance fields must be either primitive types (int, bool, etc), instances of some class that is also serializable, or marked as transient so that Java won't try to include them. A class that can not abide by those limitations should not implement Serializable (and, IIRC, the Java compiler won't even let it do so.)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值