Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem trasversing a linkedlist

 
rebs nomames
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have a small problem in one method's return value.



Although I manage to get the correct author and title when looking at author and title variable content the method only returns the reference to the linkedlist, just gibberish... If anyone can point out how to fix this it will be greatly appreciated.

thanks
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the method only returns the reference to the linkedlist, just gibberish...

I'm not sure I understand what you really want to do, but if you want to iterate through the LinkedList, why don't you use a for loop ?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by the method returns "gibberish"?
 
leroy tsruya
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i assume you try to do print to the console a Song object.
when printing to th console using System.out.print for example, you use the toString method of the class.
so you will have to override the toString method of your song class (which inherited from the Object class).
just add this method to your Song class.
as:

or whatever you choose.
i assumed you have getAuthor and getTitle methods to return the author name and title in the song class.
Hope it helped
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic