[英]How to change auto-generated code when creating new class in Eclipse
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: 每当我在Eclipse中创建一个新的Java文件并检查添加
public static void main(String args[])
,就会生成以下代码:
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
How do i: 我如何能:
@param args
comment @param args
评论 The indention is a formatting issue while the comments is a template issue. 缩进是格式问题,而评论是模板问题。
The templates are in Window -> Preferences -> Java -> Code Style -> Code Templates . 模板位于窗口 - >首选项 - > Java - >代码样式 - >代码模板中 。 Browse all of them and look for the things you would like to change.
浏览所有这些并查找您想要更改的内容。
The Formatter is a little bit more complicated. Formatter有点复杂。 You find it under Window -> Preferences -> Java -> Code Style -> Formatter .
您可以在Window - > Preferences - > Java - > Code Style - > Formatter下找到它。 There are tons of options there but I'll just answer your question.
那里有很多选择,但我会回答你的问题。
要配置它,请转到:window-> preferences-> java-> code style-> code templates
The indention is a formatting issue while the comments is a template issue. 缩进是格式问题,而评论是模板问题。
The templates are in Window -> Preferences -> Java -> Code Style -> Code Templates. 模板位于窗口 - >首选项 - > Java - >代码样式 - >代码模板中。 Browse all of them and look for the things you would like to change.
浏览所有这些并查找您想要更改的内容。
The Formatter is a little bit more complicated. Formatter有点复杂。 You find it under Window -> Preferences -> Java -> Code Style -> Formatter.
您可以在Window - > Preferences - > Java - > Code Style - > Formatter下找到它。 There are tons of options there but I'll just answer your question.
那里有很多选择,但我会回答你的问题。
* Templates -> Comments -> Methods -> Edit and delete everything
* Formatter -> Edit -> Braces Tab -> Change which situations you want
* Templates -> Code -> Method Body -> Edit and delete everything
Eclipse has a lot of configuration options. Eclipse有很多配置选项。 Take a look in the Windows |
看一下Windows | Preferences dialog (or the Eclipse Preferences pan on OSX).
首选项对话框(或OSX上的Eclipse首选项平移)。
If you dig deep enough - you'll find the options under Java | 如果你深入挖掘 - 你会在Java下找到选项 Code Style.
代码风格。
还要确保在Java>编辑器>模板中选中“使用代码格式化程序”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.