Hi I am sorry to repost this, but I am still hoping someone with a great deal of experience with complex loops may be able to help me with this rather intractable problem. (If someone can just help me with the looping problem without addressing the referencing problem, that would be great also.) Here goes again (repost): I have a series of values I am getting from an Oracle table. Let's call some of them "left values" (from the left column) and other "right values" (from the right column). For every left value, the table finds one or more (most likely more) right values. After this has been done, each right value becomes the left value, for which then more right values are found. The left values should go into the first dimension of my 2D array, the right values in the second dimension. So if I do a query for left value A and find right values B,C and D then my array will contain: myArray[A][B] myArray[A][C] myArray[A][D] However, in the second query to my table, B becomes the "left value" so that then I will need to put B in my the first dimension of my array. Suppose B finds the following right values: E and F, I have to place the following values into my array: myArray[B][E] myArray[B][F] Then on for C -> finds right values G, H and I: myArray[C][G] myArray[C][H] myArray[C][I] and so on... I am not sure what kind of complex loop I have to create to make this happen. Any help with this will be greatly appreciated. The other problem is that I do not know in advance how many values there will be, so an ArrayList may be better than an Array. However, I can find no information on two dimensional ArrayLists - how are they initialized and declared? However, there is an added complication: I need to preserve the left -> right relationships for future use so that I can display the array values in a web page in such a way that it is clear that A has rightward relationships to B, C and D, B has rightward relationships to E and F etc. So if the relationships are indicated by identical numbers I need something like this: myArray[A][B] 1 myArray[A][C] 1 myArray[A][D] 1 myArray[B][E] 2 myArray[B][F] 2 etc.. However the number should be individually associated with the left value AND with the right values, so that if I display the value of myArray[A] once only i.e. A then the values for the right relationships: B C D I should have a reference pointer in each dimension i.e. A -> ref 1 then the values for the right relationships: B -> ref 1 C -> ref 1 D -> ref 1 (otherwise I will have to always display the linked values together). So I need some sort of a hash table to be incorporated into the 2 dimensional array. A tall order, but perhaps there is someone out there who has experience with this? Any help will be greatly appreciated. Thanks very much Hugo[/B][/B][/B][/I][/B][/B][/B]