Consider the generic ArrayBag
(a) how to implement the method countOccurrences, add,remove?
(b) How to make the ArrayBag comparable?
(c) Integer i = new Integer(42);
Integer j = new Integer(43);
ArrayBag <Integer> b = new ArrayBag<Integer> ();
// Add two i’s and one j:
b.add(i);
b.add(i);
b.add(j);
Draw a diagram showing the reference variables i and j withtheir pointers to Integer objects, and also show b’s data arraywith its pointers after these add statements.
What is the printout of the following statement?
System.out.println(b.countOccurences(i);
Expert Answer
An answer will be send to you shortly. . . . .