I read online that serialization can be omitted for deri开发者_StackOverflow中文版ved objects by declaring them as transient. But, in case of linked list the links are memory references between objects. So, should I convert it to array and store the array representation?
Here's how Java serializes LinkedList: it fetches all elements and writes them to the ObjectOutputStream, together with the size. And of course declares the header entry transient
See the writeObject and readObject methods of LinkedList:
// Write out any hidden serialization magic
s.defaultWriteObject();
// Write out size
s.writeInt(size);
// Write out all elements in the proper order.
for (Entry e = header.next; e != header; e = e.next)
    s.writeObject(e.element);
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论