Answered step by step
Verified Expert Solution
Question
1 Approved Answer
An ArrayList is a special type of container that acts much like a StringBuilder class, but it can hold generic elements. The type of elements
An ArrayList is a special type of container that acts much like a StringBuilder class, but it
can hold generic elements. The type of elements an ArrayList will actually hold is usually
predetermined at declaration so a little more general than just holding characters The
elements are stored in a sequence like an array, but the array is dynamic like StringBuilder,
in that it can grow, shrink, have elements insertedremoved etc. It also supports more
functions like sorting, shuffling & reversing elements. This makes them far more powerful
than your typical array which is fixed in size
An ArrayList is generally declared along with the Type that of its elements specified inside
angle brackets Here are some sample declarations note the type in the MUST
be a reference type, you cannot use primitive types!!
ArrayList myIntList;
ArrayList myDoubleList;
ArrayList myStringList;
ArrayList myPictureList;
Each of these variables myXXXList represents a reference to an ArrayList object that
would need to be instantiated this is generally done using a default constructor, which
also uses the ArrayList format. Here are the declarations instantiations together:
ArrayList myIntList new ArrayList;
ArrayList myDoubleList new ArrayList;
ArrayList myStringList new ArrayList;
ArrayList myPictureList new ArrayList;
If instantiated this way, the list is considered an empty list of elements of the provided type,
much like an array with no elements Then through methods like add and remove
elements can be added to the list either at the end one version of add method or inserted
at a location another version of add Likewise for removing elements.
The goal of this question is to read through the input file TreasureIsland.txt and to identify
using regex matches method any words that end in ingupper or lower case Upon
finding such words, add them to an ArrayList of String elements.
Once done reading from TreasureIslandtxt you should then open a new file
wordsFoundtxt for writing see Lecture slides for information on
readingwriting to a file In this output file, write the words discovered under a title, it
should look something like this:
Words found ending in ing
word following
word HESITATING
word FIGHTING
word having
word beginning
word keeping
word nothing
word lodging
word plodding
word following
word falling
word looking
There is no tester for this question, check your output file when done there should be
thousands of words in it Make sure your pattern matching accounts for any leading
punctuation characters that are not part of the word
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started