0
Create a method with two parameters that returns the smaller of two numbers passed as parameters
When I don’t know how to solve, usually I will see the resolution with explanation, but it turns out that this time there was no English translation, only the original in Suomi :/
What is the reason for the function smallest()
do not return value?
public class AdaLovelace {
public static void main(String[] args) {
int result = smallest(1, 3);
System.out.println(result);
}
public static int smallest(int n1, int n2){
if(n1 > n2){
return n2;
} else if(n2 > n1){
return n1;
}
}
}