Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started