Java: What can and what can't be serialized?

前端 未结 9 987
Happy的楠姐
Happy的楠姐 2020-12-25 11:48

If the Serializable interface is just a Marker-Interface that is used for passing some-sort of meta-data about classes in java - I\'m a bit confused:

After reading t

9条回答
  •  时光取名叫无心
    2020-12-25 12:24

    Anything your Serializable class has in it that is not Serializable will throw this exception. You can avoid it by using the transient keyword.

    Common examples of things you can't serialize include Swing components and Threads. If you think about it it makes sense because you could never deserialize them and have it make sense.

提交回复
热议问题