Question: programs output public class PairManager { public static void main(String[] args) { Pair twoInts = new Pair (45, 21); Pair twoDbls = new Pair (42.2,

programs output

public class PairManager { public static void main(String[] args) { Pair twoInts = new Pair(45, 21); Pair twoDbls = new Pair(42.2, 19.7); Pair twoChars = new Pair('h', 'p');

System.out.println(twoInts.chooseItem()); System.out.println(twoDbls.chooseItem()); System.out.println(twoChars.chooseItem()); } }

public class Pair > { private T item1; private T item2;

public Pair(T i1, T i2) { item1 = i1; item2 = i2; }

public T chooseItem() { T chosenItem;

if (item1.compareTo(item2) < 0) { chosenItem = item1; } else { chosenItem = item2; } return chosenItem; } }

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 Accounting Questions!