Given the following Java class fragment for an UnorderedList class, write the me
ID: 3652529 • Letter: G
Question
Given the following Java class fragment for an UnorderedList class, write the method:public int indexOf(E data)
Your method "public int indexOf(E data)" returns the zero based position of the element data if it is in the list, and return -1 if it is not in the list.
A A B C D E F G
H 16 46 82 9 16 29 1
B C D E F G 0 (NULL)
H meaning the head of the list
if the method is list.indexOf(16) the method returns 0.
if the method is list.indexOf(82) the method returns 2.
if the method is list.indexOf(99) the method returns -1.
public class UnorderedList<E> {
//////////////////////////////////////
Explanation / Answer
public int indexOf(Object o){ for(int i = 0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.