关键字:transient

2017-10-23  本文已影响6人  kangkaii

发现地点: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

上一篇下一篇

猜你喜欢

热点阅读