Please can anybody help me with my code? I cannot find my error. It get the error message " min variable might not been initialized". But it has been . Thank you.
public class Solution {
public static int min(int a, int b, int c) {
int min;
if (a <= b && a <= c) {
min = a;
}
else if (b <= a && b <= c) {
min = b;
}
if (c<= b && c <= a) {
min = c;
return min;
}
public static void main(String[] args) throws Exception {
System.out.println(min(1, 2, 3));
System.out.println(min(-1, -2, -3));
System.out.println(min(3, 5, 3));
System.out.println(min(5, 5, 10));
}
minimum of the three int numbers
Under discussion
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
sourav bamotra
8 October 2020, 07:21
give initial value to min.i.e
and correct your if-else and return's statement.
^_^ 0
Nina Tuttle
10 October 2020, 03:02
Thank you so much for your help
0
sourav bamotra
10 October 2020, 05:26
your welcome :)
0