Question: Consider a version of the LinkedList class of Section 16.1.8 in which the addFirst method has been replaced with the following faulty version: Develop a
Consider a version of the LinkedList class of Section 16.1.8 in which the addFirst method has been replaced with the following faulty version:

Develop a program ListTest with a test case that shows the error. That is, the program should print a failure message with this implementation but not with the correct implementation.
public void addFirst(Object element) { } Node newNode= new Node (); first = newNode; newNode.data newNode.next = element; = first;
Step by Step Solution
3.35 Rating (167 Votes )
There are 3 Steps involved in it
The given method addFirst has a logical error When creating a new node and inserting it at the beginning of the linked list it should set the newNoden... View full answer
Get step-by-step solutions from verified subject matter experts
