Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Node Class and Singly Linked List

807605Oct 1 2007 — edited Oct 2 2007
My goal is to create a singly linked list that holds integer data. Ive read the chapter from my cs book on it twice and am still a little lost because of the way they designed the example so Im taking it slow. The first thing is the Node Class:
 
public class Node
{ 
    int number; 
    Node next; 

    public Node()
    { 
        number = null; 
        next = null; 
    } 

    public Node (int number, Node next)
    { 
        this.number = number; 
        this.next = next; 
    } 

    public String toString()
    { 
        return number; 
    } 
}
Does this look ok? Do I need a toString or will the LinkedList class that I create take care of that? Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 30 2007
Added on Oct 1 2007
6 comments
943 views