Question: This assignment is in Java: import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Scanner; public class ArrayListExcercise { public static void main(String[] args) {
This assignment is in Java:
import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Scanner;
public class ArrayListExcercise { public static void main(String[] args) { //1. Add all the colors in the colors.txt file to an ArrayList. //Use a Scanner class to open the "colors.txt" file. //Read the whole file adding each color to an ArrayList. //Your ArrayList should store String's. e.g. ArrayList
//3.Insert the String Black into index 2. See add method. //a.Print the values of the ArrayList to the console using a loop //4. Retrieve the String at index 3 and print it to the console. See get method. //5. Remove the String at index 0 from the ArrayList. See remove method. //a. Print the values of the ArrayList to the console using a loop //6. Update the array element at index 3 with the String Tan. See set method. //a. Print the values of the ArrayList to the console using a loop
colors.txt:
White Aquamarine Azure Bisque Blue Brown Burlywood Blue Chartreuse Chocolate Coral Cornsilk Cyan Goldenrod Green Orange Orchid Gray Pink Blue
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
