Question: All of this is in java, the function headers are given 1. I want to make a Node class with Object data and Node next.
All of this is in java, the function headers are given
1. I want to make a Node class with Object data and Node next. Create an empty constructor and a 2 arg constructor.
2. Then I want to make a function nodeToString() that takes a head Node (which may be null). The returned String should look something like this: [A, B, C, D]
public static String nodeToString(Node h) {
}
3. Then I want to make a function get() that takes a head Node and an int index. get() should return the Object in the nth Node. Start indexing at 0. If the index is out of bounds, return null.
public static Object get(Node h, int index) {
}
4. Then I want to make a function add() that takes a Node and an Object and adds the Object to the end of the Node list. Because the Node list might start as null, we will return the head Node.
public static Node add(Node h, Object obj) {
}
5. Then I want to make a function add() that takes a Node, an Object, and an int n, and adds the Object n spots after the head Node. When n = 0, it should add the new String into the front and move every other element back one spot.
public static Node add(Node h, Object obj, int n) {
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
