public void addLast(E el) { // 10 pts 26. To the same class on the previous page, complete method as a method in LinkedList removeAll(E element) so it removes occurrences of from any LinkedList object. Assume type has an all LinkedList<E> element E equals method. These assertions must pass. (16pts) LinkedList<String> list = new LinkedList<String>(); list.addFirst("B"); list.addFirst("A"); list.addFirst("B"); list.addFirst("B"); assertEquals("[B, B, A, B]", list.toString()); assertEquals(3, list.size()); list.removeAll("B"); assertEquals("[A]", list.toString()); assertEquals(1, list.size()); public void removeAll(E element) {
public void addLast(E el) { // 10 pts 26. To the same LinkedList class on the previous page, complete method removeAll(E element) as a method in LinkedList<E> so it removes all occurrences of element from any LinkedList object. Assume type E has an equals method. These assertions must pass. (16pts) LinkedList<String> list = new LinkedList<String>(); list.addFirst("B"); list.addFirst("A"); list.addFirst("B"); list.addFirst("B"); assertEquals("[B, B, A, B]", list.toString()); assertEquals(3, list.size()); list.removeAll("B"); assertEquals("[A]", list.toString()); assertEquals(1, list.size()); public void removeAll(E element) {
227PracticeMidTermSum15.docx