How do you simplify the max method in Listing 1 using the conditional operator?
LISTING 1 TestMax.java
1 public class TestMax {
2 /** Main method */
3 public static void main(String[] args) {
4 int i = 5;
5 int j = 2;
6 int k = max(i, j);
7 System.out.println("The maximum of " + i +
8 " and " + j + " is " + k);
9 }
10
11 /** Return the max of two numbers */
12 public static int max(int num1, int num2) {
13 int result;
14
15 if (num1 > num2)
16 result = num1;
17 else
18 result = num2;
19
20 return result;
21 }
22 }
![]()

We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.