Question: Write a method in the HashIntSet class called retainAll that accepts another hash set as a parameter and removes all elements from this set that

Write a method in the HashIntSet class called retainAll that accepts another hash set as a parameter and removes all elements from this set that are not contained in the other set. For example, if the set stores [-2, 3, 5, 6, 8] and the method is passed [2, 3, 6, 8, 11], your set would store [3, 6, 8].

Step by Step Solution

3.34 Rating (166 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public void retainAll HashIntSet other for int i 0 i element Datalength i i... View full answer

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 Building Java Programs A Back to Basics Approach Questions!