Java“? :"运营商? [英] Java "? :" operator?

查看:149
本文介绍了Java“? :"运营商?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

什么是Java?:运算符被调用,它做了什么?

我可以知道什么是java?:运算符调用,我试图找到它是如何工作的信息,但我不知道它叫什么,输入?:在google中没有给出正确的结果。

may i know what is the java ?: operator called, i am trying to find information on how it works but i do not know what is it called, typing ?: in google dont give a correct result.

推荐答案

这是条件运算符。

有些人称之为三元运算符,但这只是说它有多少个操作数。特别是,Java的未来版本可以(完全合理地)引入另一个三元运算符 - 而运算符的 name 是条件运算符。

Some people call it the ternary operator, but that's really just saying how many operands it has. In particular, a future version of Java could (entirely reasonably) introduce another ternary operator - whereas the name of the operator is the conditional operator.

第15.25条语言规范


条件运算符? :使用一个表达式的布尔值到
决定应该评估两个其他表达式中的哪一个。

The conditional operator ? : uses the boolean value of one expression to decide which of two other expressions should be evaluated.

这篇关于Java“? :"运营商?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆