Question: Type the program's output public class ItemChoice { public static T chooseItem(T item1, T item2, T item3) { T chosenItem = item1; if (item2.compareTo(chosenItem) >
Type the program's output
public class ItemChoice {
public static
T chooseItem(T item1, T item2, T item3) {
T chosenItem = item1;
if (item2.compareTo(chosenItem) > 0) {chosenItem = item2; }
if (item3.compareTo(chosenItem) > 0) {chosenItem = item3; }
return chosenItem; }
public static void main(String[] args) {
Integer i1 = 8; Integer i2 = 6; Integer i3 = 7;
Character c1 = 'b'; Character c2 = 'y'; Character c3 = 'z';
String s1 = "silver"; String s2 = "khaki"; String s3 = "cyan";
System.out.println(chooseItem(c1, c2, c3));
System.out.println(chooseItem(i1, i2, i3));
System.out.println(chooseItem(s1, s2, s3));
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
