Question: import java.util.ArrayList; public class ArrayListUtil { /** Removes adjacent duplicates from an array list of strings. @param word an array list of strings */ public

import java.util.ArrayList; public class ArrayListUtil { /** Removes adjacent duplicates from an array list of strings. @param word an array list of strings */ public static void removeAdjacentDuplicates(ArrayList words) { . . . } }

import java.util.Arrays; import java.util.ArrayList; public class Tester { public static void main(String[] args) { ArrayList words1 = new ArrayList(Arrays.asList( "Typing a a word twice is is a common mistake".split(" "))); ArrayListUtil.removeAdjacentDuplicates(words1); System.out.println(words1); System.out.println("Expected: [Typing, a, word, twice, is, a, common, mistake]"); ArrayList words2 = new ArrayList(Arrays.asList( "Typing a word three times is is is not so common".split(" "))); ArrayListUtil.removeAdjacentDuplicates(words2); System.out.println(words2); System.out.println("Expected: [Typing, a, word, three, times, is, not, so, common]"); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!