Problem:
Given three int values, a b c, return the largest.
intMax(1, 2, 3) → 3
intMax(1, 3, 2) → 3
intMax(3, 2, 1) → 3
Solution:
public int intMax(int a, int b, int c) { int temp1 = Math.max(a,b); int temp2 = Math.max(temp1, c); return temp2; }
public int intMax(int a, int b, int c) {
ReplyDeletereturn Math.max(Math.max(a, b), c);
}