Question: --Using Java-- Define two bags of type string. Add some strings to bag1 such as apple, orange or pear. Add some strings to bag2. You

--Using Java--

Define two bags of type string. Add some strings to bag1 such as apple, orange or pear.

Add some strings to bag2. You are going to write a method called intersection that returns a

bag that contains common items between the two bags.

To solve this problem, first start with two bags and display them. Make sure you can display

both bags correctly. Then write a method to check if there is any common items between the

bags at all. So that method should return true or false.Once these work, try to write the intersection method.

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!