【问题标题】:why the header attribute of linked list is set as transient为什么链表的header属性设置为transient
【发布时间】:2015-01-04 17:12:22
【问题描述】:

如果一个属性设置为瞬态,那么它就不能被序列化,我想知道为什么 LinkedList 中的 Entry 标头设置为瞬态。部分源代码如下: 公共类链表{ 私有瞬态条目头 = 新条目(空,空,空); ... }

【问题讨论】:

    标签: java linked-list


    【解决方案1】:

    这是因为 LinkedList 使用它自己的方法进行序列化。请参阅 LinkedList 的 writeObject 和 readObject 方法。

    编辑: 从 J. Bloch 购买或租用 Effective Java 书籍并阅读第 11 章中的第 75 条;-)

    【讨论】:

      猜你喜欢
      • 2010-11-10
      • 2011-07-24
      • 1970-01-01
      • 1970-01-01
      • 2022-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-19
      相关资源
      最近更新 更多