java arraylist help needed
<p>Have coded in many languages before but new to Java.
I want to create an array whose members are of type </p>

<pre><code>public class data
    {
        String date="";
        String time="";
        double  price=0;
        int volume=0;
    };

    data data1 = new data();
    public ArrayList ftsedata = new ArrayList&lt;data&gt;();
</code></pre>

<p>I then get market data which i insert into data1 followed by</p>

<pre><code>ftsedata.add(data1);
</code></pre>

<p>I then wait for fresh data and when i get it I insert it AGAIN into data1 and add it to ftsedata. Although ftsedata seems to be increasing in size correctly it seems that elements of ftsedata are just pointers to data1 and hence all elements of ftsedata seems to have values equal to the last data1 values.</p>

<p>I am using arraylist because I do not know how many datapoint will come in during the day so i need something that expands.</p>

<p>Could someone please tell me if I should be using arraylist or something else and if arraylist what is my problem.</p>

<p>many thanks for your time.</p>

<hr>

<p>Many Thanks everyone,</p>

<p>I actually have four different functions that each fill one part of data1. Taking your views on board, i left data1 alone as a variable that can be seen in all functions. In the particular function that adds data1 to the arraylist i created a dataLocal variable of type Data and copied everything into it like
dataLocal.price= data1.price;
etc etc
I then added dataLocal to the arraylist.  This seems to work.
I am assuming that each time this function is called a new local variable with the name dataLocal is created. Thanks you all for your help and please let me know if there is somethimng in this way of doing things that can get me in trouble later,eg, some other part of program would write over one instance of dataLocal because as far as the program is concerned the need for the variable is over.</p>
