ArrayList ArrayList is a variable group implementation that implements all methods of the List interface, and allows access to NULL values. ORRAYLIST basically equivalent to Vector, but it only synchronizes WriteObject () and readObject (). 1. Serialization ArrayList uses an Object's array storage element. Private transient e [] ElementData; ArrayList implements the java.io.Serializable interface, here the Transient indicates that this property does not require automatic serialization. This is because the "element" stored in the ElementData array is actually Just a reference to these elements is not a real object, sequentialization is meaningless. Because serialization is in deserialization, when you reach, the reference is not possible to point to the original object. So ArrayList the elements manually performed operation sequence, this is the role writeObject () a. private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException {// Write out element count, and any hidden stuff s.defaultWriteObject ();
// Write out Array Length S.WriteInt (ElementData.Length);
// Write Out All Elements in The Proper ORDER. FOR (INT i = 0; i // read in array length length = sready int arch; object [] a = elementdata = (e []) New Object [arraylength]; // read in all Elements in The Proper ORDER. FOR (INT i = 0; I Public E Remove (int index) {RangeCheck (Index); Modcount ; e oldvalue = elementdata [index]; INT Nummoved = Size - INDEX - 1; if (Nummoved> 0) System.Arraycopy (ElementData, Index 1, ElementData, Index, Nummoved); ElementData [- size] = null; // let GC DO ITS WORK