java中的返回值语法 [英] Return value syntax in java
本文介绍了java中的返回值语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不太确定这个方法是做什么的,或者更好的是我不确定:"是什么意思.有人可以帮我理解吗?
private int guess(){返回 isTrue() ?答:isFalse() ?乙:都没有()?丙:丁;}
解决方案
这是一个嵌套的三元运算符
a> 具有 a 的形式?b : c
其计算结果为:
if (a) then b, else c
<小时>
所以你的问题可以分解为:
if (isTrue()) {返回A;} else if(isFalse()) {返回 B;}否则如果(都没有()){返回 C;} 别的 {返回 D;}
I am not really sure what this method does, or better I am not sure what " : " means. Can someone please help me understand?
private int guess( )
{
return isTrue( ) ? A : isFalse( ) ? B : neither( ) ? C : D;
}
解决方案
This is a case of nested ternary operators which have the form a ? b : c
which evaluates to:
if (a) then b, else c
So your question breaks down to this:
if (isTrue()) {
return A;
} else if(isFalse()) {
return B;
} else if(neither()) {
return C;
} else {
return D;
}
这篇关于java中的返回值语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文