java - 如何在 Java 中打断长行

标签 java formatting word-wrap conventions

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/

相关文章:

jsf - 在 JSF 中格式化 double

c# - PdfPTable 作为 iTextSharp 中的标题

C#/WPF : Disable Text-Wrap of RichTextBox

python textwrap 在错误的地方打破句子

c# - 在非托管 C++ 代码中使用 C# 属性

java - JFrame 关闭按钮的弹出窗口

java.lang.NumberFormatException : For input string: "id"

java - 如何从 Windows 运行 ZooInspector

java - 将对象列表转换为接口(interface)列表时出错

c# - 我需要 c# 中的一些东西,它像 c++ 中的 setw() 一样工作