private void writeObject(java.io.ObjectOutputStream s)
        throws java.io.IOException {
        // Write out any hidden serialization magic
        s.defaultWriteObject();

        // Write out size
        s.writeInt(size);

        // Write out all elements in the proper order.
        for (Node<E> x = first; x != null; x = x.next)
            s.writeObject(x.item);
    }
private void writeObject ( java . io . ObjectOutputStream s ) throws java . io . IOException { s . defaultWriteObject ( ) ; s . writeInt ( size ) ; for ( Node < E > x = first ; x != null ; x = x . next ) s . writeObject ( x . item ) ; }
Saves the state of this {@code LinkedList} instance to a stream
(that is, serializes it).

@serialData The size of the list (the number of elements it
contains) is emitted (int), followed by all of its
elements (each an Object) in the proper order.