Hi   
   My question is not really related to Struts, but i thought i could ask
you guys about this so that i can get some answer &
   this might help some developers.
   When i looked at the source code for Sun's Java class ArrayList  i found
something interesting.
   The private member of the ArrayList class, which holds the objects added
to list, is transient which means indication to the Java virtual machine
that the indicated variable is not part of the persistent state of the
object. 
   So My question is 
   if i have an ArrayList object, can i save this object into a file & read
the same object from the file without loosing data ? 
   (Keep in mind the member variable,  private transient Object
elementData[]; , which holds tha actual data is transient in ArrayList)

   Please see below for Some code from java.util.ArrayList.java 
   
Thanks in advance
Ramana 

public class ArrayList extends AbstractList implements List, Cloneable,
                                                    java.io.Serializable {

    private transient Object elementData[];

    private int size;

    public ArrayList(int initialCapacity) {
        super();
        this.elementData = new Object[initialCapacity];
    }

    public ArrayList() {
        this(10);
    }

    public ArrayList(Collection c) {
        size = c.size();
        elementData = new Object[(size*110)/100]; // Allow 10% room for
growth
        c.toArray(elementData);
    }

    public void trimToSize() {
        modCount++;
        int oldCapacity = elementData.length;
        if (size < oldCapacity) {
            Object oldData[] = elementData;
            elementData = new Object[size];
            System.arraycopy(oldData, 0, elementData, 0, size);
        }
    }

 }

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to