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

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 Databases Questions!