NetBeans Java 代码格式化程序:新行上的逻辑运算符

发布于 2024-09-03 04:38:18 字数 333 浏览 3 评论 0原文

我的代码如下所示:

if (firstCondition() &&
        secondCondition()) {
    // ... code
}

NetBeans 中代码格式化程序的默认设置希望将 &&在新行上,如下所示:

if (firstCondition()
        && secondCondition()) {
    // ... code
}

格式化程序运行良好,因此我只想找到设置,以便它不会将代码更改为后者。那个设定叫什么?

My code looks like this:

if (firstCondition() &&
        secondCondition()) {
    // ... code
}

The default settings for the code formatter in NetBeans wants to put the && on a new line, like this:

if (firstCondition()
        && secondCondition()) {
    // ... code
}

The formatter works well so I would just like to find the setting so it doesnt change the code to the latter. Whats the setting called?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

洒一地阳光 2024-09-10 04:38:18

工具>选项>编辑>格式化
语言> Java
类别>换行

逻辑运算符本身没有选项,但请尝试使用If 语句二元运算符 并查看其工作原理。

如果这还不够,您可能需要查看 JIndent

Tools > Options > Editor > Formatting
Language > Java
Category > Wrapping

There's no option for logical operators per se, but try the If Statement and Binary Operators and see how that works.

If that doesn't go far enough, you may want to check out JIndent.

躲猫猫 2024-09-10 04:38:18

你说的是哪个版本,因为我的 6.7.1 绝对不这样做!它也没有选择这样做。

Which version are u talking about, because my 6.7.1 definitely doesn't do that! It also doesn't have an option to do so.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文