21.2k views
5 votes
g Create a public non-final generic class called YourSimpleLinkedList. You should extend SimpleLinkedList which is parameterized with a single type parameter E. Implement a single public method named search. search takes as a parameter a single reference of the same type as the type parameter and returns true if the list contains the element and false otherwise. If search is passed a null reference you should throw an IllegalArgumentException.

1 Answer

5 votes

Answer:

See explaination

Step-by-step explanation:

class YourSimpleLinkedList<E> extends SimpleLinkedList<E> {

public boolean search(E value) {

if (value == null)

throw new IllegalArgumentException();

Item temp = start;

while (temp != null) {

if (temp.value.equals(value))

return true;

temp = temp.next;

}

return false;

}

}

User Nathan Schubkegel
by
5.2k points