What is the Java ?: operator called and what does it do?

前端 未结 16 1716
轮回少年
轮回少年 2020-11-21 05:27

I have been working with Java a couple of years, but up until recently I haven\'t run across this construct:

int count = isHere ? getHereCount(index) : getAw         


        
16条回答
  •  感动是毒
    2020-11-21 06:05

    Its Ternary Operator(?:)

    The ternary operator is an operator that takes three arguments. The first 
    argument is a comparison argument, the second is the result upon a true 
    comparison, and the third is the result upon a false comparison.
    

提交回复
热议问题