Question: import java.util.HashSet;import java.util.ArrayList;public class SetORList{ public static void main(String[] args){ ArrayList list = new ArrayList(); HashSet set = new HashSet(); int size = 100; System.out.print(making

HashSet The HashSet class in the JCF implements the Set ADT. A

import java.util.HashSet;import java.util.ArrayList;public class SetORList{        public static void main(String[] args){                ArrayList list = new ArrayList();                HashSet set = new HashSet();                                int size = 100;                                System.out.print("making collections... ");                for(int i=0; i

HashSet The HashSet class in the JCF implements the Set ADT. A set is an unordered collection of unique items. Imprtant methods include add, contains, remove, isEmpty and size. https://docs.oracle.com/javase/8/docs/api/java/util/HashSet.html import jave.util.HashSet; HashSet set = new HashSet (); Run the SetORList program. Rerun the program several times with different values of size (see the main method). Try 1000, 10000, 20000, 50000, etc. What can we say about using an ArrayList and using a HashSet? Modify the SetORList to generate a collection of 10 items (Integers for example). Sort the ArrayList (using Collections.sort). How do you sort the data in the set?

Step by Step Solution

3.49 Rating (146 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Electrical Engineering Questions!