Skip to main content

 

FEED
From 30,000+ hand-picked sources

public class IntNode { // Invariant of the IntNode class: // 1. The node's integer data is in the instance variable data. // 2. For the final node of a list, the link part is null. // Otherwise, the link part is a reference to the // next node of the list. private int data; private IntNode link; /** * Initialize a node with a specified initial data and link to the next * node. Note that the initialLink may be the null reference, * which indicates that the new node has nothing after it. * @param initialData * the initial data of this new node * @param initialLink * a reference to the node after this new node--this reference may be null * to indicate that there is no node after this new node. * @postcondition * This node contains the specified data and link to the next node. **/ public IntNode(int initialData, IntNode initialLink) { data = initialData; link = initialLink; } /** * Modification method to add a new node after this node. * @param item * the data to place in the new node * @postcondition * A new node has been created and placed after this node. * The data for the new node is item. Any other nodes * that used to be after this node are now after the new node. * @exception OutOfMemoryError * Indicates that there is insufficient memory for a new * IntNode. **/ public void addNodeAfter(int item) { link = new IntNode(item, link); } /** * Accessor method to get the data from this node. * @param - none * @return * the data from this node **/ public int getData( ) { return data; } /** * Accessor method to get a reference to the next node after this node. * @param - none * @return * a reference to the node after this node (or the null reference if there * is nothing after this node) **/ public IntNode getLink( ) { return link; } /** * Copy a list. * @param source * the head of a linked list that will be copied (which may be * an empty list in where source is null) * @return * The method has made a copy of the linked list starting at * source. Read More

Advertisement
Node

Biography

Including producers Flood and Ed Bueller with Dave Bessel and Gary Stout, Node use analogue synth instruments to recreate a... Read the full Node bio.

Node

Exclusives

Hot Music News

More on AOL Music