更新时间:2023-11-10 09:14:34
这是理解重要性的一个例子运营商优先权。
This is an example of the importance of understanding operator precedence.
您需要括号,否则会被解释如下:
You need the parentheses otherwise it is interpreted as follows:
String test = ("test" + testInteger) == null ? "(null)" : testInteger.toString();
请参阅这里列出了运营商及其优先顺序。另请注意该页面顶部的警告:
See here for a list of operators and their precedence. Also note the warning at the top of that page:
注意:甚至可能出现混淆时使用明确的括号。
Note: Use explicit parentheses when there is even the possibility of confusion.