Possible Duplicate:
What is the Java ?: operator called and what does it do?
In some code a ? is used to perform a mathematical equation.
What is it and how do you use it? Is it possible to provide an example and the reason for the final answer of an equation?
int count = getChildCount();
int top = count > 0 ? getChildAt(0).getTop() : 0;
Run Code Online (Sandbox Code Playgroud)
基本上是三元运算符:
String mood = (isHappy == true)?"I'm Happy!":"I'm Sad!";
Run Code Online (Sandbox Code Playgroud)
如果是快乐,那么"我很开心!"."我伤心!" 除此以外.
| 归档时间: |
|
| 查看次数: |
18355 次 |
| 最近记录: |