Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Turn an object reference into useful data?

 
Jacob Morehouse
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • 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
 
K. Tsang
Bartender
Posts: 3348
12
Android Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic