Question: Create an integer set by adding elements in the following order ( 10, 17, 2 , 7, 4, 11, 2 , 1, 4, 7, 15).
Create an integer set by adding elements in the following order ( 10, 17, 2 , 7, 4, 11, 2 , 1, 4, 7, 15). Create this set object using different classes of sets namely, TreeSet and HashSet. Print the sets for all these three objects, what do you observe? Write the code to a) print only even numbers present in the set. b) delete only odd elements from the set Can for each loop be used for both (a) and (b) ? What do you use then? Please explain.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
