Home > Back-end >  Java can't write, Java beginners have a small small problems
Java can't write, Java beginners have a small small problems

Time:09-24


As shown in figure, modification method is let me add a return value, or into a void type, I would be a little meng, pleaded with bosses,

CodePudding user response:

The last line else if (a CodePudding user response:

One less the else return;

CodePudding user response:

The
refer to the original poster zwyjason response:

As shown in figure, modification method is let me add a return value, or into a void type, I would be a little meng, pleaded with bosses give directions,


Positive solution to the second floor, there is need to consider all the situation when the return value, you are actually no problem, but the return on the logic as long as there is an if must need to have the else, so the compiler can not pass,

CodePudding user response:

reference 1st floor Aleac response:
last line else if (a

Ok thank you!!!!!!

CodePudding user response:

refer to the second floor chao reply:
one less the else return;

Thank you very much!!!!!!

CodePudding user response:

Compiler will think you don't meet all the conditions of no return value, so make you into a void or a return,

CodePudding user response:

reference qq_39936465 reply: 3/f
Quote: refer to the original poster zwyjason response:

As shown in figure, modification method is let me add a return value, or into a void type, I would be a little meng, pleaded with bosses give directions,


Positive solution to the second floor, there is need to consider all the situation when the return value, you are actually no problem, but the return on the logic as long as there is an if must need to have the else, so the compiler can not pass,

So!! Learn to remember!! Thank you!!!!!

CodePudding user response:

Recommend beginners a good coding standards, even if the condition is only one line of code in the body, also want to take braces, and the line and indent code
  • Related