Page 2 of 2 FirstFirst 12
Results 21 to 22 of 22
  1. #21
    clerd is offline Member
    Join Date
    Apr 2013
    Rep Power

    Default Re: LinkedList question

    Quote Originally Posted by Norm View Post
    That is the String returned by the default (Object class) toString() method.
    You should override all the class's toString() methods to return the String you want to see when the linked list is printed.

    You should add ID Strings in all the println()s so you can easily recognize what was printed. For example:
    Java Code:
    System.out.println("an ID "+ THEVARIABLENAMEHERE);
    Change "an ID" to be the message you want to see, for example the name of the variable.
    I know this doesn't work, but would I do something like this in the main?

    Java Code:

  2. #22
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    On vacation
    Rep Power

    Default Re: LinkedList question

    Did you add the toString() method to all the classes? Adding that will change what is printed.

    See the Object class's API for what the method's signature looks like. Be sure to put an @Override notation immediately before the method definition.
    If you don't understand my response, don't ignore it, ask a question.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Quick question to do with LinkedList exercise
    By SAH101 in forum New To Java
    Replies: 3
    Last Post: 08-27-2012, 06:35 PM
  2. linkedlist question
    By stuckonjava in forum New To Java
    Replies: 2
    Last Post: 05-06-2012, 04:37 AM
  3. Question about LinkedList Iterator
    By kraigballa in forum New To Java
    Replies: 7
    Last Post: 02-10-2012, 06:10 PM
  4. Java newbie question on linkedlist index search
    By Mjall in forum New To Java
    Replies: 5
    Last Post: 03-25-2011, 11:54 PM
  5. Quick LinkedList question
    By mac in forum New To Java
    Replies: 7
    Last Post: 05-31-2010, 01:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts