英文:
I'm not sure what this java row does
问题
int iEnd = i == grid.length - 1 ? 0 : 1;
英文:
I should probably know that but I'm not sure what this line of code is doing:
int iEnd=i==grid.length - 1 ? 0:1;
答案1
得分: 0
它将在i等于grind.length - 1时将iEnd设置为0,否则将iEnd设置为1。
这个操作符被称为“三元运算符”,是“条件运算符”的简写形式,你可以在这里阅读更多关于它的信息:https://docs.oracle.com/javase/tutorial/java/nutsandbolts/op2.html https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html
英文:
it will set iEnd to 0 if i equals grind.length -1 otherwise it will set iEnd to 1
the operator is called Ternary Operator
and is a short hand for a Conditional Operator
and you can read more about it here: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/op2.html
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论