I am busy for a long time with this task, but I cannot figure out how the min(a, b, c, d) method can use the min(a, b) method.
package com.codegym.task.task02.task0217;
/*
Minimum of four numbers
*/
public class Solution {
public static int min(int a, int b, int c, int d) {
if ((a<=b) && (a<=c) && (a<=d))
return a;
if ((b<=a) && (b<=c) && (b<=d))
return b;
if ((c<=a) && (c<=b) && (c<=d))
return c;
else
return d;
}
public static int min(int a, int b) {
int m2;
if (a<b)
m2 = a;
else
m2 = b;
return m2;
}
public static void main(String[] args) throws Exception {
System.out.println(min(-20, -10));
System.out.println(min(-20, -10, -30, -40));
System.out.println(min(-20, -10, -30, 40));
System.out.println(min(-40, -10, -30, 40));
}
}