GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes problem trasversing a linkedlist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "problem trasversing a linkedlist" Watch "problem trasversing a linkedlist" New topic
Author

problem trasversing a linkedlist

rebs nomames
Greenhorn

Joined: Dec 27, 2009
Posts: 1
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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 ?


[My Blog]
All roads lead to JavaRanch
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What do you mean by the method returns "gibberish"?
leroy tsruya
Ranch Hand

Joined: Sep 24, 2009
Posts: 57
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
 
GeeCON Prague 2014
 
subject: problem trasversing a linkedlist