Convert the following program into one that uses an array object, String a[], instead of an ArrayList object. Write a class [MyName]ArrayList, which can replace the ArrayList< String > type declarations in the code below. Be sure to support the same behavior currently provided by the ArrayList object, include:
import java.util.*;
public class ArrayListExercise {
public static void main(String[] args) {
ArrayList< String > aList = new ArrayList< >();
Scanner fileReader;
fileReader = new Scanner(new ArrayListExercise().
getClass().getResourceAsStream("myWords.txt"));
Scanner keyboardReader = new Scanner(System.in);
String inFilePath, line, word;
int size = 0;
while (fileReader.hasNext()) {
line = fileReader.nextLine();
if (line == null) {
break;
}
aList.add(line);
} // while not end of file
System.out.print("\n\nPlease enter the word you want to search for: ");
word = keyboardReader.nextLine();
if (aList.indexOf(word) >= 0) {
System.out.println(word + " was found.\n\n");
} else {
System.out.println(word + " was not found.\n\n");
}
System.out.print("Please enter the word you want to remove: ");
word = keyboardReader.nextLine();
int removalCount = 0;
while (aList.remove(word)) {
removalCount++;
}
if (removalCount == 0) {
System.out.println(word + " was not found, so not removed.\n\n");
} else if (removalCount == 1) {
System.out.println("The only instance of " + word + " was removed.\n\n");
} else {
System.out.println("All " + removalCount + " instances of " + word
+ " were removed.\n\n");
}
System.out.print("Please enter the word you want to append: ");
word = keyboardReader.nextLine();
aList.add(word);
System.out.println(word + " was appended.\n\n");
System.out.print("Please enter the word you want to upper case: ");
word = keyboardReader.nextLine();
int position = aList.indexOf(word);
if (position >= 0) {
aList.set(position, word.toUpperCase());
System.out.println(word + " was converted to upper-case.\n\n");
} else {
System.out.println(word + " was not found, so not upper-cased.\n\n");
}
System.out.println("Here is the final version:\n" + aList);
} // method main
}