Hi I got this problem with I am not sure how to deal with… I have a Linked List which stores Objects which works fine. But now I am trying to display the content of the linked list using iterator and I understand that wont be as simple as
ListIterator<String> iterator = LibraryUser.listIterator();
iterator = LibraryUser.listIterator();
while (iterator.hasNext())
System.out.println(iterator.next());
because of the type… Is there way to do this ?
OH RIGHT! I need to override toString don’t i…
If all you know is that LibraryUser contains instances of
Object(that is, you don’t know that they areStringinstances), you can use:or, more simply: