在Eclipse中创建新类时如何更改自动生成的代码 [英] How to change auto-generated code when creating new class in Eclipse

查看:155
本文介绍了在Eclipse中创建新类时如何更改自动生成的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我在Eclipse中创建一个新的Java文件并检查添加 public static void main(String args [])的选项时,将生成此代码: p>

Whenever I create a new Java file in Eclipse and check off the option to add public static void main(String args[]), this code is generated:

public class Test {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

    }

}

我如何:


  • 删除 @param args comment

  • 更改缩进,使每个{在一行自己的

  • 删除TODO自动生成的评论

  • Remove the @param args comment
  • Change the indentation so each { is on a line of its own
  • Remove the TODO auto generated comment

推荐答案

缩进是格式化问题而这些注释是模板问题。

The indention is a formatting issue while the comments is a template issue.

模板位于窗口 - >首选项 - > Java - >代码样式 - >代码模板中。浏览所有这些,并查找您想要更改的内容。

The templates are in Window -> Preferences -> Java -> Code Style -> Code Templates. Browse all of them and look for the things you would like to change.

格式化程序有点复杂。您可以在窗口 - >首选项 - > Java - >代码样式 - >格式化器下找到它。有很多选择,但我只是回答你的问题。

The Formatter is a little bit more complicated. You find it under Window -> Preferences -> Java -> Code Style -> Formatter. There are tons of options there but I'll just answer your question.


  • 模板 - >评论 - >方法 - >编辑和删除所有内容

  • 格式化程序 - >编辑 - >大括号选项卡 - >更改所需的情况

  • 模板 - >代码 - >方法体 - >编辑和删除一切

这篇关于在Eclipse中创建新类时如何更改自动生成的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆