Question: In the below code, implementation of clone() for the IntSet class is wrong. Do the following: (a) Provide a correct implementation of clone() for IntSet,
In the below code, implementation of clone() for the IntSet class is wrong. Do the following: (a) Provide a correct implementation of clone() for IntSet, and give appropriate JUnit tests. (b) Correctly override hashCode() and equals(). ---- import java.util.*; public class IntSet implements Cloneable { private List els; @Override public boolean equals(Object obj) { // Standard recipe if (!(obj instanceof IntSet)) return false; IntSet s = (IntSet) obj; return false; } @Override public int hashCode() { // see below return 42; } public IntSet () { els = new ArrayList(); } private IntSet (List list) { els = list; } @Override public IntSet clone() { return new IntSet (new ArrayList(els)); } } Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
