Need help implementing this method. All the methods that are in the interface are already implemented. Need help with the last one in both classes ArrayList and Linked List 3. Consider a member method reverse() for the List ADT that returns a new List with the elements in reversed order. For example if a List L-(Bob, Mel, Ron, il Ron), then a call to Lreverse will return a new list M = (Ron, Jil, Ron, Mel, Bob). The old list Lis not affected. The prototype for the method is a follows: public List
reversel Add this method to the interface and implement for the ArrayList and LinkedList classes. The method returns an empty list if the list Lis empty. @Override public List reverse() { 2080 209 210 211 212 return null; public interface List extends Iterable { public void add(E obj); public void add(int index, E obj); public boolean remove(E obj); public boolean remove(int index); public int removeAll(E obj); public E get(int index); public E set(int index, E obj); public E first(); public E last(); public int firstIndex(E obj); public int lastIndex(E obj); public int size(); public boolean isEmpty(); public boolean contains(E obj); public void clear(); public int replaceAll (E e, Ef); public List reverse(); 19 21 22 ) 3 import java.util.Iterator; 8 public class ArrayList implements List { // private fields private E elements[]; private int currentSize; 8. public class LinkedList implements List { private class Node { private E value; private Node next; public Node(E value, Node next) { this.value = value; this.next = next; public Node (E value) { this(value, null); // Delegate to other constructor public Node() { this(null, null); // Delegate to other constructor public E getValue() { return value; public void setValue(E value) { this.value = value; public Node getNext() { return next; public void setNext(Node next) { this.next = next; public void clear() { value = null; next = null; } // End of Node class private class ListIterator implements Iterator { private Node nextNode; public ListIterator() { nextNode = header.getNext(); @Override public boolean hasNext() { return nextNode != null; @Override public E next() { if (hasNext()) { E val = nextNode.getValue(); nextNode = nextNode.getNext(); return val; ww else throw new NoSuchElementException(); } // End of ListIterator class 0 von w Il private fields private Node header; private int currentSize