I try to add multiple object in ArrayList, this is my code
ArrayList<WordData> unique = new ArrayList<WordData>();
WordData tempWordData = new WordData();
for(int i=0;i<3;i++)
{
String temp_word = word.get(i);
tempWordData.addWord(temp_word);
unique.add(tempWordData);
}
but, all the data in unique
ArrayList
was word.get(2)
, not word.get(0), word.get(1), word.get(2)
Please help, thanks