简体   繁体   中英

Queue/LinkedList serialization in Java

I have an implementation of a queue (Queue class, which is basically a linked list) - it consists of linked list of objects of Element class (with Previous/Next references) and a header for first and last element, which is also an object of Element class. I would like to serialize the Queue. The question is - how to serialize a bidirectional linked list?

There is a lot of ways to do that. You can implement Serializable and take care about persisting all the objects. You can save all the data and relations in some structured XML. You can go with JSON.

The only problem can be if your Queue is generic (like the one in the standard library), you are going to have hard time saving an object of unknown type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM