Article View: borland.public.jbuilder.java.language
Article #17557Re: Vector addElement method question
From: Tad Frysinger
Date: Fri, 30 Oct 1998 00:00
Date: Fri, 30 Oct 1998 00:00
28 lines
1706 bytes
1706 bytes
In article <3639BB48.F4C8CBC7@jhmi.edu>, lelliot@jhmi.edu says... > After performing a query, I am placing the contents of the result row in > a class that I have defined. I then use addElement to add that class to > a vector. I am performing this logic (both placing the result row in a > class and then adding that class to a vector) in a loop to process the > entire query result set. When I view the contents of the vector in > debug mode, it appears as though each addElement execution updates all > currently populated vector objects with the most current result set > row. So, when the loop is complete, for example, vector size is 10 and > all 10 objects are the last row from the result set. > Is there something that I am missing ? Can a vector be populated in > this manner from a result set ? > > Thanks for any help. > > Lisa > > Sounds to me like you are using a variable to populate the vector, and the contents of the variable change - not the reference in the vector which would be to the same variable. Thus, at the end, since the vector has the same reference in all elements, they are all pointing to whatever ended up being in that variable. or something like that... Tad Frysinger [TeamB]
Technical Details
Message-ID:
<MPG.10a3e84a35f61cd5989954@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<3639BB48.F4C8CBC7@jhmi.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,35c3abf5ac4f8dcd X-Google-Attributes: gidf74b3,public From: tfrysinger@uswest.net (Tad Frysinger) Subject: Re: Vector addElement method question Date: 1998/10/30 Message-ID: <MPG.10a3e84a35f61cd5989954@forums.borland.com> X-Deja-AN: 406819969 References: <3639BB48.F4C8CBC7@jhmi.edu> Organization: FreeZone Enterprises Newsgroups: borland.public.jbuilder.java.language