Explain the function of the following methods in LinkedList 1.
addFirst(E e) 2.
contains(E e) 3.
get(int index) 4. i
ndexOf(E e) 5.
remove() 6.
remove(int index) 7.
set(int index, E e)
Solution
1. addFirst(E e):
It adds an element e at head of linked list
2. contains(E e):
It searches element e in list.
If it is in list, it returs true otherwise false
3. get(int index):
this return element at index \'index\'
4. indexOf(E e):
this return index of element e in list if it is in list.
Otherwise it return -1
5. remove()
it removes last element from list
6. remove(int index)
it delete element at index \'index\'
7. set(int index, E e):
it replaces element at index \'index\' with element e
.