Lab 03
Array Lists
Download the driver
and the Lorem Ipsum text
file and place them in your project directory.
Create a class ArrayListUtils with
the following (static) methods:
-
removeDuplicates Removes duplicates
from an ArrayList of Characters.
The remaining character from the duplicates is always the first occurrence
-
params
-
data The ArrayList to remove
duplicates from.
-
return An ArrayList with no duplicate entries remaining.
-
getCommonStrings Finds the strings
common to both given ArrayLists.
If both lists contain the same entry multiple times, the
resulting list should contain the entry exactly once.
-
params
-
list1 An ArrayList
of Strings
-
list2 An ArrayList
of Strings
-
return An ArrayList of
Strings common to both list1
and list2
-
wordRecall Reads in lines
from a text file, then asks the user for a line number
and a word number. Then, does one of the following:
-
If the number/word choice is invalid, displays an
appropriate error message
-
If the user enters 'quit', exits the loop (but not the program)
-
Otherwise, prints the word at the given position
-
param
-
fname The name of the file
to read in.
Your class should not have a main method
You are not allowed the use of any arrays, even if you do not directly
create them. For example, the split
method on strings returns an array, and therefore is not allowed.
Enter a line number and a word number, separated by a space, or type 'quit' to quit.
1 1
Lorem
Enter a line number and a word number, separated by a space, or type 'quit' to quit.
18 3
semper
Enter a line number and a word number, separated by a space, or type 'quit' to quit.
40 6
turpis
Enter a line number and a word number, separated by a space, or type 'quit' to quit.
quit
removeDuplicates Passed
getCommonStrings Passed
Upload the .java file to the dropbox
Make sure it conforms to the style guidelines