What’s the difference between Java – serialized objects because they can persist?

We know that serializable is a tag interface (that is, an interface without any methods)

So I want to know how to implement this interface to make the object of the implementation class persistent. This interface has nothing except the name serializable

We get any other functionality by implementing this interface

Can we create a similar markup interface and do the same work with different names? (this question is just to try.)

Edit: I can extend the serializable interface And the extension interface will have the same properties

Solution

It sounds simple, but it's not

This interface is only used to ensure that developers understand and understand the consequences of serialization (only send the required data to the line and avoid sending useless information by marking it as transient)

If you don't use it, you may put a lot of useless bytes on the line Applications that use serialization spend most of their perceived execution time transmitting data to disk or over the network

By forcing developers to say "yes, I want to do this", I hope they will say at least one minute (do I want to serialize these big data that can be calculated later?)

This does not always happen

No, that's it

No, it's special You can try to customize the serialization mechanism, but this is a different story

When using serialization, you must pay attention to many other things, such as security and flexibility To this end, I suggest you read

Item 74: implement serializable wisely in effective java book

Here is how the project starts:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>