First of all I am a student, I'm in a data structures class.

Well I'm having trouble coming up with a getNext method to be used in a linked list class. I am trying to write a getNext method that I can to find out if the list contains a certain int.
I'm not sure if that is a good enough description... just trying to find out how to work my way through a linked list really, I can't seem to figure it out!

9 Years
Discussion Span
Last Post by Jocamps

Keep in mind that each node in a LinkedList contains a "NEXT" pointer, which points to the next node and/or a "previous" pointer which points to the previous node. You may set-up a Node class which contains the element of that node and the pointers:

public class Node{
    Node next;
    Node prev; //this is optional 
    Object element; //this could be any types 
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.