爪哇”? :”操作员?
嗨,我可以知道 java ?: 运算符被称为什么吗,我正在尝试查找有关它如何工作的信息,但我不知道它叫什么,在 google 中输入 ?: 不给出正确的结果。
Possible Duplicate:
What is the Java ?: operator called and what does it do?
hi, 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这是条件运算符。
有些人将其称为三元运算符,但这实际上只是说它有多少个操作数。特别是,Java 的未来版本可以(完全合理地)引入另一个三元运算符 - 而该运算符的名称是条件运算符。
请参阅语言规范的第 15.25 节:
It's the conditional operator.
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.
See section 15.25 of the language specification:
三元是您要找的词。
ternary is the word you are looking for.
因此,Java 语言规范正式将其称为(三元)条件运算符。
Thus, the Java Language Specification officially calls it the (ternary) conditional operator.
这被称为三元或条件运算符(取决于你问的是谁)
它允许你执行单行条件语句,例如在这个伪代码中,正如
Jon Skeet 所说,它的正确名称是条件运算符,但它有 3 个操作数,所以三元运算符。
This is known as the ternary or conditional operator (depending on who you ask)
It allows you to do single line conditional statements such as in this pseudocode
As Jon Skeet notes, it's proper name is the conditional operator, but it has 3 operands so is a ternary operator.
你的意思是 if else 语句吗?查一下“ternery”这个词。
等于:
Do you mean for an if else statement? Look up the word ternery.
equates to:
它被称为条件运算符,但通常被称为三元运算符(这是一类运算符,全部采用 3 个操作数,但在 Java 中只有一个这样的存在,即条件运算符)
有时它被称为三元运算符,这只是一种语言(英语)用法错误
事件这个< /a> 适用于 c#,同样适用于 Java
it's called the conditional operator but very often called ternary operator (which is a class of operators all taking 3 operands however in Java only one such exits namely the conditional operator)
some times it's called the tertiary operator which is simply a language (english) usage error
Eventhouigh this is for c# the same applies to Java