This question already has answers here:
Short form for Java if statement
                            
                                (15个答案)
                            
                    
                3个月前关闭。
        

    

谁能告诉我这句话是什么意思? getHead是整数列表中的第一个整数:

        return (a.getHead() > m)? a.getHead():m;


谢谢

最佳答案

与以下内容相同:

if((a.getHead() > m))
     return a.getHead();
else
     return m;


这是其背后的想法:

if ' evaluate condition' ? 'what to do if condition is true' : 'what to do if condition is false'

10-08 17:22