Java Copy the following code to a java file and explain in the comment what is the output and why. 1- ArrayList list = new ArrayList(); for (int i = 1; i


Java


Copy the following code to a java file and explain in the comment what is the output and why.


1- ArrayList list = new ArrayList();


for (int i = 1; i <= 10;="" i++)="">


list.add(10 * i);


}


for (int i = 0; i < list.size();="" i++)="">


list.remove(i);


}


System.out.println(list); // what is the expected output?


2- ArrayList list = new ArrayList();


for (int i = 1; i <= 10;="" i++)="">


list.add(10 * i);


}


  int size = list.size();


for (int i = 0; i < size;="" i++)="">


list.add(i, 42);


}


System.out.println(list); // what is the expected output?



Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here