Answered step by step
Verified Expert Solution
Link Copied!

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

image

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

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

Recommended Textbook for

Introduction to Java Programming, Comprehensive Version

Authors: Y. Daniel Liang

10th Edition

133761312, 978-0133761313

More Books

Students also viewed these Electrical Engineering questions