public static int min(int a,int b)
int m2;
if (a<b)
a=m2;
else
b=m2;
return m2;
in the solution code when I mentioned (a=m2 ; and b= m2;in the place of m2=a; or m2=b; ) then why it shown me error .
Under discussion
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
rsmith
24 June 2019, 02:14
I believe the minimum should equal a or b. You have a and b equaling the min. If you switch it around, it should work.
+1
Chinwe Ibegbu
22 June 2019, 15:52
I am not too sure but I think that m2 has not been given any value yet. You declared it but assigned no value so it has a null value. You see? So, when you assigned m2 to a or b, it threw an error. That's my understanding. I hope I helped.
0