Question: public class DefaultIntPair implements IntPair { private int firstNum, secondNum; public DefaultIntPair(int firstNum, int secondNum) { this.firstNum = firstNum; this.secondNum = secondNum; } public int

 public class DefaultIntPair implements IntPair { private int firstNum, secondNum; public

DefaultIntPair(int firstNum, int secondNum) { this.firstNum = firstNum; this.secondNum = secondNum; }

public class DefaultIntPair implements IntPair { private int firstNum, secondNum; public DefaultIntPair(int firstNum, int secondNum) { this.firstNum = firstNum; this.secondNum = secondNum; } public int first() { return firstNum; } public int second() { return secondNum; } public String toString() { return ""; } public boolean equals(Object o) { if (this == o) return true; if (o == null) return false; DefaultIntPair intPair = (DefaultIntPair) o; return firstNum == intPair.firstNum && secondNum == intPair.secondNum; } public IntPair reverse() { DefaultIntPair reversedPair = new DefaultIntPair(secondNum, firstNum); return reversedPair; } }

c) 2 Nowgeneralize the IntPair interface by making it generic in the item type of the pair.allow ing us to store two items not only of type int but of arbitrary reference type as long as both items are of that same type. Show the code (or explain what needs to be changed) for the resulting generic interface Pair

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!