Question: java We have written the following Node class, but we have forced the type of its data instance variable to be String. However, we would
java
We have written the following Node class, but we have forced the type of its data instance variable to be String. However, we would like for it to be generic such that a Node can be instantiated with any type of data TASK: Update the following Node class such that it can be instantiated with any type of data using Java generics Sample Input: Sample Output: Write a program, test using stdin stdout Time limit: 8 seconds Memory limit: 256 MB 1 /** * Node class to contain data class Node { /** * The data contained in this Node */ private final String data; /** * Create a new Node with the given data * @param data The desired data of the new Node */ public Node (String data) { this.data = data; /** * Get the data of this Node * @return The data of this Node */ public String getData() { return this.data
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
