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

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "problem trasversing a linkedlist" Watch "problem trasversing a linkedlist" New topic

problem trasversing a linkedlist

rebs nomames

Joined: Dec 27, 2009
Posts: 1

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.

Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

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

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.

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
I agree. Here's the link:
subject: problem trasversing a linkedlist
It's not a secret anymore!