This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

UrlyBird : ArrayList problem

 
Anthony Erickson
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Philippe Maquet
Bartender
Posts: 1872
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anthony,
Welcome to this forum.
What you seem to overwrite is the String rec[] in this loop :

Cheers,
Phil.
 
Anthony Erickson
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Phillipe. I'll have to give that a shot. Looks like lack of Much appreciated
 
Anthony Erickson
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1872
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Philippe! It works now. Looks like a Java 101 Error (:eek on my part.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic