Coded in many languages before, but new to Java. I want to create an array whose members are of type
public class data
{
String date="";
String time="";
double price=0;
int volume=0;
};
data data1 = new data();
public ArrayList ftsedata = new ArrayList<data>();
Then I get market data, which I insert into data1, and then
ftsedata.add(data1);
Then I wait for the fresh data, and when I receive it, I insert it into file1 and add it to ftsedata. Although ftsedata seems to grow in size correctly, it seems that the ftsedata elements are just pointers to data1, and therefore all ftsedata elements seem to have values equal to the last values of data1.
I use arraylist because I don't know how much data will go in during the day, so I need something that expands.
Can someone tell me if I should use arraylist or something else, and if arraylist, what is my problem.
Thank you very much for your time.
Thanks everyone
, 1. , data1 , . , data1 arraylist, dataLocal Data
dataLocal.price = data1.price;
..
dataLocal arraylist. , .
, , dataLocal, . , , , - , -, , , - dataLocal, , .