Question: MyArrayList is defined in Listing 24.2. Write a program that generates 1000000 random double values between 0 and 999999 and stores them in a MyArrayList

MyArrayList is defined in Listing 24.2. Write a program that generates 1000000 random double values between 0 and 999999 and stores them in a MyArrayList and in a MyHashSet. Generate a list of 1000000 random double values between 0 and 1999999. For each number in the list, test if it is in the array list and in the hash set. Run your program to display the total test time for the array list and for the hash set.

Data from Listing 24.2.

1 publ1c class MyArrayList 1mplementS MyList { publ1c stat 1c f1nal 1nt

INITIAL CAPACITY = 16: private E[] data = (E[]) new Object[INITIAL CAPACITY]:

private int size = 0: // Number of elements in the list

2 3 4 5 6 ** Create an empty list / 7


1 publ1c class MyArrayList 1mplementS MyList { publ1c stat 1c f1nal 1nt INITIAL CAPACITY = 16: private E[] data = (E[]) new Object[INITIAL CAPACITY]: private int size = 0: // Number of elements in the list 2 3 4 5 6 ** Create an empty list / 7 pub11c MyArrayList () { 9 10 * Create a list from an array of objects /

Step by Step Solution

3.41 Rating (173 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

import javautilScanner import javautil public class Exercise2710 public static void mainString args MyHashSet set new MyHashSet MyArrayList list new MyArrayList for int i 0 i 1000000 i double value Ma... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Introduction to Java Programming and Data Structure Questions!