• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

UrlyBird : ArrayList problem

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Philippe! It works now. Looks like a Java 101 Error (:eek on my part.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic