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> {
//////////////////////////////////////