In the following code, the vector of arrays, all contain the same value, yet as you can see, by the System.out display, there are definitely unique values in the Iterator. Why are all of the vector entries being overwritten by the last values inserted? I orginally tried this as loading a vector of vectors and that had problems too, so I moved to a vector of
String arrays.
Vector data = new Vector();
public void loadTableData(Map BBtally)
{
Collection entries = BBtally.entrySet();
Iterator it = entries.iterator();
String[] rowData = {"",""};
while(it.hasNext())
{
Map.Entry em = (Map.Entry)it.next();
rowData[0] = em.getKey().toString();
System.out.println(em.getKey());
rowData[1] = em.getValue().toString();
System.out.println(em.getValue());
data.addElement(rowData);
}
}
Values as they appear in Vector afterwards. As I step through debug I can see these values change to the last value loaded into rowData.
data = Vector
[0] =(string[])
[0] = "2004"
[1] = "1"
[1] =(string[])
[0] = "2004"
[1] = "1"
[2] =(string[])
[0] = "2004"
[1] = "1"
[3] =(string[])
[0] = "2004"
[1] = "1"
Values being displayed in System.out:
2001
2
2002
4
2003
1
2004
Appreciatively,
Gary