Sorry for not being clear enough. The above was just a quick example to try and show what i am trying to achieve.
What i am trying to achieve is to store the data in objects. The data itself has a one to many relationship. This means that many names will be related to the same sequence number. I would like to store the common names (i.e. those with the same seq no) in the same object in an arraylist.
Maybe this data structure makes more sense
What im hoping to achieve is the following
- The seq object will contain one seq row (either 1,2,3,4,5,6) - Array list in the seq object should contain all the rows for each individual seq. - As an example if seq.seq = 6, the seq.namePcs() should contain all NamePcs objects tha t have id's (30,31,32,33).
Here is what i am hoping to achieve as the end result (for the first 6 rows)
I hope that made it a bit clear.
Thanks [ September 23, 2008: Message edited by: O. Ziggy ]
Joined: Oct 13, 2005
Your Name class is badly designed if it has public fields and a field called almost the same as the class.
You are going to have to get the seq_no into an int, then when you loop, if (seq_no > seq.size()) you can add a new object to your larger list. Then for each line you can try seq.get(seq_no - 1).addToList(new NamePcs(id, total));
And you ought not to use plain simple ArrayList; it ought to be ArrayList<NamePcs>.
I have assumed your seq_no starts at 1; you will need to change the logic if it doesn't start at 1 or if there are gaps in the sequence.
Change nameList to seq to match your posting.[/edit] [ September 23, 2008: Message edited by: Campbell Ritchie ]