Question
Need help writing a few methods in the Generic Node class....and if you could tell me if you see any issues with the methods I
Need help writing a few methods in the Generic Node class....and if you could tell me if you see any issues with the methods I have already written, it would be appreciated
*addNodeAfter() instead of being void, returns the link it creates....just want to make sure my method header is correct and the return type (Node) is correct, or if i need Node
*removeNodeAfter() returns the link it creates (that is the node after the removed element....just want to make sure my method header is correct and the return type (Node) is correct
* toString() creates and returns a string message which reveals the stored value(data) but not the link (non-recursive method documented below is the class, constructor, and a few methods i have written so far...this is part of a much larger project so if anything is unclear as far as specifications, I can provide it
CODE----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
public class Node
/** * 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 Node(E initialData, Node
public Node addNodeAfter(E element) { return link = new Node
public Node addNodeAfter(E element) { return link = new Node
Any help is greatly apprecitated.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started