Results 1 to 2 of 2
  1. #1
    ohiopotato is offline Member
    Join Date
    Oct 2010
    Rep Power

    Default Someone help me with this method?

    I've written a method to fetch a node from a linked list, but it returns null for a unsuccessful search even when I know that the node exists. coudl anyone help me out with this?

    public T fetch(String incoming)
    Key previous;
    Key here = (Key) head;
    Key toSend = null;
    for(int i = 1; i <= this.size; i++)
    previous = here;
    here = previous.getNext();
    toSend = here;

    return (T) toSend;

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power


    Debug it, or println() it, to see what values all those things hold.
    That is incoming, here, previous,

Similar Threads

  1. Thread problem, calling method in run method
    By majk in forum Threads and Synchronization
    Replies: 4
    Last Post: 09-27-2010, 12:40 PM
  2. Turning Recursion Method into Iterative method
    By mattakuevan in forum New To Java
    Replies: 9
    Last Post: 06-15-2010, 07:46 AM
  3. Replies: 2
    Last Post: 03-26-2010, 06:12 PM
  4. ArrayLists compareTo method, equals method
    By random0munky in forum New To Java
    Replies: 2
    Last Post: 10-26-2009, 08:20 PM
  5. cannot call private method from static method
    By jon80 in forum New To Java
    Replies: 3
    Last Post: 05-07-2008, 09:37 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