Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes UrlyBird : ArrayList problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "UrlyBird : ArrayList problem" Watch "UrlyBird : ArrayList problem" New topic
Author

UrlyBird : ArrayList problem

Anthony Erickson
Greenhorn

Joined: Dec 18, 2003
Posts: 6
Hello Everyone. I've found this website to be incredible useful in getting through the assignment.
I'm currently a bit on a problem with ArrayLists (URLyBird List getRecord() ). Everytime I add a field[] array to the ArrayList, it overwrites all previously added field[] arrays.


Any idea on how to get around this?


Sun Certified Java Programmer<br />Sun Certified Web Component Developer<br />Sun Certifed System Administrator<br />Sun Certified Network Administrator<br />BEA Weblogic Certified Developer
Philippe Maquet
Bartender

Joined: Jun 02, 2003
Posts: 1872
Hi Anthony,
Welcome to this forum.
What you seem to overwrite is the String rec[] in this loop :

Cheers,
Phil.
Anthony Erickson
Greenhorn

Joined: Dec 18, 2003
Posts: 6
Thanks, Phillipe. I'll have to give that a shot. Looks like lack of Much appreciated
Anthony Erickson
Greenhorn

Joined: Dec 18, 2003
Posts: 6
Hmm....Just tested the code out. I'm still stumped.
The first get() correctly pulls out the key, value pair.
The second get(), which is outside of the loops, shows that ALL values are set to the last added value.
Any ideas?
Philippe Maquet
Bartender

Joined: Jun 02, 2003
Posts: 1872
Hi Anthony,
The first get() correctly pulls out the key, value pair.
The second get(), which is outside of the loops, shows that ALL values are set to the last added value.

Normal I think : I don't see that you create a *new* fields array at each step in the for loop on rowCount.
Regards,
Phil.
Anthony Erickson
Greenhorn

Joined: Dec 18, 2003
Posts: 6
Thanks Philippe! It works now. Looks like a Java 101 Error (:eek on my part.
 
wood burning stoves
 
subject: UrlyBird : ArrayList problem
 
Similar Threads
NX: URLyBird 1.3.3 -- EOFException
NX: URLyBird Database Record Number Question
URLyBird: Read data file
URLyBird db format
URLyBird: Reading the db-File