Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java! Dont Forget to Iterate 1. Create a static void method that takes an ArrayList as its input parameter and outputs each element of

In Java! Dont Forget to Iterate

image text in transcribed

1. Create a static void method that takes an ArrayList as its input parameter and outputs each element of the ArrayList to the screen You can use this function as a template to get started: public static void PrintList(ArrayList list) You are required to iterate through the list. You may use an iterator or a for loop, but go through the list and print each item. - Do not simply call System.out.println(list); This will not receive full credit. 2. In the main method: A. Create an ArrayList of doubles - Add the following values to the list in this order - 1.5 - First value - 2.35 - Second value - -4.7 - Third value - 0.01 - Fourth value B. Print the list using the PrintList method designed in step 1. C. Sort the list by calling the Collections.sort method - This method takes a single parameter, the list you want sorted. - There is an option for a second parameter, the comparator function to use, but we aren't going to use it. Only pass one parameter to Collections.sort. D. Print the list again using the PrintList method E. Call the Collections.binarySearch method to search the list for the value 1.5. - This method takes two parameters, the list you want to search and the value you want to search for (1.5 in this case). - This method returns an integer value. This is the index of the item that was found. F. Print the index where 1.5 was found. G. Call the Collections.fill method to zero out the list. - This method takes two parameters, the list you want to change and the value you want to fill it with (0.0 in this case). H. Print the list again using the PrintList method

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions