ArrayList<Integer> highPrices = new ArrayList<>();
for (int i = 0; i < prices.size(); i++) {
Integer currentPrice = prices.get(i);
if (currentPrice > 80) {
highPrices.add(currentPrice);
}
}
System.out.println("Step 1 output is: " + highPrices);
ArrayList<Integer> newList = (ArrayList<Integer>) prices.clone();
newList.retainAll(highPrices);
System.out.println("Step 2 output is: " + newList);
// What is the output of the program?
// The output of the program is the ArrayList highPrices and the ArrayList newList.
// What is the output of the program if the instructions that will follow are:
// Write code that will create the ArrayList trips.
// Write the program "UAE 'Abu Dhabi 101 Italy Rome Canada" that will create a new list named capitals.
// Extracted from the list you created in Step 1, how many days should be spent in each capital?
// Paris: 2 days
// Rome: 1 day
// All other capitals: 3 days