• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Turn an object reference into useful data?

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello!


This is probably an easy one, but for some reason my searches turn up nothing. I'm possibly Googling this wrong? Anywho, here's my code:


This results in references to those objects, like "passwordgeneratorfx.Password@41b192cc." I've given the Password class a method of "getPaswordContents" that returns a string value, but I cannot seem to reference it here. How would I call that method here on each object in the list?

Thanks,
Jake
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jacob Morehouse wrote:Hello!


This is probably an easy one, but for some reason my searches turn up nothing. I'm possibly Googling this wrong? Anywho, here's my code:


This results in references to those objects, like "passwordgeneratorfx.Password@41b192cc." I've given the Password class a method of "getPaswordContents" that returns a string value, but I cannot seem to reference it here. How would I call that method here on each object in the list?

Thanks,
Jake



Hello Jake

Have you consider using the for-each loop?



If you get the "passwordgeneratorfx.Password@41b192cc" then the object is referring to the internal "toString()" method. You can override the toString() method to give you what you want.
 
Jacob Morehouse
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Of course after giving up and posting, I solve it:


And away we go! Still getting used to generics. Also, welcoming any better or more concise solutions. There's always someone out there with a better way to skin the proverbial cat.

Thanks,
Jake
 
reply
    Bookmark Topic Watch Topic
  • New Topic