I have a linkedlist with different objects in it's nodes. I don't know how can i print objects of it??
my code is: i don't know what i write in the body of dispalyData method? in this linked list we have objects of manager class , laborer class ... that each of them has special fields . but all of them have name, last name and idnumber fields.
Sheila Jorge wrote:I have a linkedlist with different objects in it's nodes. I don't know how can i print objects of it??
I'm waiting for your help
Again, it depends what you mean by "print".
All classes have a toString() method that you can override, and this is normally used to provide some sort of text-based representation of the instance.
I suspect (at least to start with) that's all you'll need; if you need anything more involved, you might consider a Printable interface (maybe with a print() method), and have all your list classes implement it. That way, your list can simply be a List<Printable>.
Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here