Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

As all the member variables of java LinkedList is transient, what will be the use of implementing Serializable?

Tags:

java

1) In LinkedList implementation all the 3 member varaibles size, first, last are transient, then what is the use of implementing serializable?

2) What will be persisted when we try to serialize a LinkedList?

like image 354
user3510364 Avatar asked Sep 19 '14 03:09

user3510364


1 Answers

You'll notice LinkedList has writeObject and readObject methods. These write/read the size of the list and write/read each object in the list.

Note that these methods (but also the fields) are private so the implementation may change. Don't depend on it. Depend on the interfaces.

like image 87
Sotirios Delimanolis Avatar answered Sep 28 '22 02:09

Sotirios Delimanolis