在official document of Oracle about coding conventions他们写道:
"Following are two examples of breaking an arithmetic expression. The first is preferred, since the break occurs outside the parenthesized expression, which is at a higher level."
longName1 = longName2 * (longName3 + longName4 - longName5)
+ 4 * longname6; // PREFER
longName1 = longName2 * (longName3 + longName4
- longName5) + 4 * longname6; // AVOID
“更高级别”是什么意思?与表达式中的求值顺序有关吗?
最佳答案
来自官方文档的先前声明:
"Prefer higher-level breaks to lower-level breaks"
换句话说,避免因可读性而破坏嵌套表达式。
表达式嵌套在括号中的次数越多,级别越低。
关于java - 如何在 Java 中打断长行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48312781/