美文网首页
关键字:transient

关键字:transient

作者: kangkaii | 来源:发表于2017-10-23 11:09 被阅读6次

发现地点:ArrayList类的 Object[] elementData属性

/**
* The array buffer into which the elements of the ArrayList are stored.
* The capacity of the ArrayList is the length of this array buffer. Any
* empty ArrayList with elementData == DEFAULTCAPACITY_EMPTY_ELEMENTDATA
* will be expanded to DEFAULT_CAPACITY when the first element is added.
*/
    transient Object[] elementData; // non-private to simplify nested class access

使用原因:
ArrayList 实现了 java.io.Serializable;
这个类的有些属性需要序列化,而其他属性不需要被序列化;
所以,transient Object[] elementData。


参考:http://blog.csdn.net/zxl315/article/details/5359151

相关文章

  • Java基础题

    transient和volatile是java关键字吗? transient是变量修饰符。标记为transient...

  • Effective Java 序列化

    AtomicReference transient java 的transient关键字 只需要实现Seriliz...

  • transient关键字是什么

    transient关键字是什么

  • Java Transient关键字

    1、transient关键字只能修饰变量,而不能修饰方法和类。2、被transient关键字修饰的变量不再能被序列...

  • 不想进行序列化

    对于不想进行序列化的变量,使用transient关键字修饰。 transient关键字的作用是:阻止实例中那些用此...

  • Java Volatile transient 关键字

    Java Volatile transient 关键字 java关键字volatile Volatile修饰的成员...

  • Java中各种关键字

    java transient 关键字与序列化Java关键字——instanceofvolatile关键字浅析Jav...

  • 无标题文章

    # java关键字## 一、transient### transient的作用及使用方法如何将非静态的数据不进行序...

  • Java transient 关键字

    问:transient 关键字能实现什么? 答:当对象被序列化时(写入字节序列到目标文件)时,transient ...

  • 关键字——Transient

    transient 的用途 Q:transient 关键字能实现什么? A:当对象被序列化时(写入字节序列到目标文...

网友评论

      本文标题:关键字:transient

      本文链接:https://www.haomeiwen.com/subject/hewouxtx.html