как засунуть функцию в функцию ?
а правильно ли так , как я сделал, если переменная аd из метода min( int a, int b)
не ссылается на переменную в другой функции.
package com.javarush.task.task02.task0217;
/*
Минимум четырех чисел
*/
public class Solution {
public static int min(int a, int b, int c, int d) {
int ab, bc, ad;
if (a < b) ab = a;
else ab = b;
if (c < ab) bc = c;
else bc = ab;
if (d < bc) ad = d;
else ad = bc;
return ad;
//напишите тут ваш код
}
public static int min(int a, int b) {
int ad;
if (a < b) ad = a;
else ad = b;
return ad;
//напишите тут ваш код
}
public static void main(String[] args) throws Exception {
System.out.println(min(-20, -10));
System.out.println(min(-40, -10, -30, 40));
System.out.println(min(-20, -40, -30, 40));
System.out.println(min(-20, -10, -40, 40));
System.out.println(min(-20, -10, -30, -40));
}
}