有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java有没有一种方法可以让NetBeans在单独的一行中自动创建括号?

例如,当我创建一个新类时,我得到:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package helloworld;

/**
 *
 * @author Sergio
 */
public class WordManipulations{        
}

我讨厌这样放括号。有没有办法让它创造出这样的东西:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package helloworld;

/**
 *
 * @author Sergio
 */
public class WordManipulations 
{

}

共 (3) 个答案

  1. # 1 楼答案

    在Netbeans中,进入工具选项。然后选择格式化选项卡,并在语言下拉列表下选择Java

    现在有几个选项可以按您喜欢的方式更改格式

  2. # 2 楼答案

    还有JIndent插件

  3. # 3 楼答案

    只需遵循以下步骤:

    1. 导航到Tools -> Options -> Editor
    2. 导航到Editor -> Formatting
    3. 选择以下选项
      • 语言:Java
      • 类别:大括号
    4. 在“类声明、方法声明等”中
      • 大括号放置:新行