Consider the follow ArrayLis in Javat:
ArrayList centennials = new ArrayList<>();
centennials.add(LocalDate.of(1776, Month.JULY, 4));
centennials.add(LocalDate.of(1876, Month.JULY, 4));
centennials.add(LocalDate.of(1900, Month.JULY, 4));
centennials.add(LocalDate.of(1976, Month.JULY, 4));
centennials.add(LocalDate.of(2076, Month.JULY, 4));
As you can observe, a java program author has mistakenly entered a 1900 item into the ArrayList. Without removing the associated centennials.add(...) source line, write the code to remove the errant entry. Print out the resulting ArrayList and size as follows:
Before removal:
07/04/1776
07/04/1876
07/04/1900
07/04/1976
07/04/2076
size = 5
After removal:
07/04/1776
07/04/1876
07/04/1976
07/04/2076
size = 4
Hint: you should use the DateTimeFormatter class for formatting
Code:
import java.io.*;
import java.time.LocalDate;
import java.time.Month;
import java.util.*;
public class arraylist {
public static void main(String[] args)
{
ArrayList centennials=new ArrayList<>();
//Adding data to Array list
centennials.add(LocalDate.of(1776, Month.JULY, 4));
centennials.add(LocalDate.of(1876, Month.JULY, 4));
centennials.add(LocalDate.of(1900, Month.JULY, 4));
centennials.add(LocalDate.of(1976, Month.JULY, 4));
centennials.add(LocalDate.of(2076, Month.JULY, 4));
System.out.println("Before removel:\n");
System.out.println(centennials); //To print the dates before
removal of 1990
System.out.println("Size="+centennials.size()); //Find the size of
the array list before removel of 1990
centennials.remove(2); //Remove the element at index '2'
System.out.println("After removal:\n");
System.out.println(centennials); //To print the dates after removal
of 1990
System.out.println("Size="+centennials.size()); //Find the size of
the array list after removal of 1990
}
}
Output:
![<terminated> arraylist [Java Application] C:\Program Files Vava\jdk1.8.0_73\bin\javaw.exe (19-Nov-2019, 11:44:07 PM) Before r](http://img.homeworklib.com/questions/aa546830-bf27-11ea-bbea-fda39bdfab00.png?x-oss-process=image/resize,w_560)
Consider the follow ArrayLis in Javat: ArrayList centennials = new ArrayList<>(); centennials.add(LocalDate.of(1776, Month.JULY, 4)); centennials.add(LocalDate.of(1876, Month.JULY,...
Consider the follow ArrayList: ArrayList centennials = new ArrayList<>(); centennials.add(LocalDate.of(1776, Month.JULY, 4)); centennials.add(LocalDate.of(1876, Month.JULY, 4)); centennials.add(LocalDate.of(1976, Month.JULY, 4)); centennials.add(LocalDate.of(2076, Month.JULY, 4)); Write the code necessary to determine the ArrayList size. Sample output: Question 7 size = 4
10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated sludge operation that adversely affect effluent quality with origins in the engineering, hydraulic and microbiological components of the process. The real "heart" of the activated sludge system is the development and maintenance of a mixed microbial culture (activated sludge) that treats wastewater and which can be managed. One definition of a wastewater treatment plant operator is a "bug farmer", one who controls the aeration...