Home > Back-end >  Why should Num assignment does not complain, why is this?
Why should Num assignment does not complain, why is this?

Time:12-24

CodePudding user response:

Because you are all the if else if cause the compiler can't know that you will ultimately assignment, so will let you let you assignment, when declaring variables, if you end up with a face in the else Num assignment, so the first line assignment can not,,

CodePudding user response:

 
Public static int getMinValue (int a, b int, int) c {
Int Num.
If (a & lt; B & amp; & A. & lt; C) {
Num=a;
} else if (b & lt; A. & amp; & B & lt; C) {
Num=b;
} else if (c & lt; A. & amp; & C & lt; B) {
Num=c;
} else {
Num=b;
}
Return Num.
}


So there will be no error
  • Related