| Author |
ArrayList Problems, Help needed
|
edu njoro
Greenhorn
Joined: Mar 23, 2011
Posts: 2
|
|
Help needed please.
The Arraylist, det, below behaves as if I am adding the same object again and again. Clearly within the while loop
I am creating a new instance of the Detail class on each iteration. Using this instance I am able to set the various properties.
However, the code that follows the while loop i.e. the for..each give me the same value x times, x being the number of records
in the resultset rs.
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16687
|
|
Do your setter methods make copies of your gc, un, uname, and uno objects? Or are they pointing to the objects that you pass?
In the second case, you will create an array list of different detail objects -- all of which are pointing to the same gc, un, uname, and uno object.
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
edu njoro
Greenhorn
Joined: Mar 23, 2011
Posts: 2
|
|
Henry,
You are Great!, I struggled with this for hours not ending.
I just needed to create a new instance of the gc,uno,un and uname objects in each iteration.
Thanks Henry!!!
|
 |
 |
|
|
subject: ArrayList Problems, Help needed
|
|
|