如何让 Eclipse 为新的 Java 类自动生成 main 方法?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20726033/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you get Eclipse to auto-generate a main method for a new Java class?
提问by
Does anyone know a reason why my Eclipse does not preload
有谁知道我的 Eclipse 没有预加载的原因
public static void main(String[] args)
when I create a new class? What can I do to make it appear automatically?
当我创建一个新类时?我该怎么做才能让它自动出现?
采纳答案by Paul Samsotha
"what can i do to make it appear automatically? "
“我该怎么做才能让它自动出现?”
- Go to create New Java Class dialog
- See a part that says "Which method stubs would you like to create?"
- check
public static void main(String[] args)
- 转到创建新 Java 类对话框
- 看到“您想创建哪个方法存根?”的部分。
- 查看
public static void main(String[] args)
回答by Asheesh
Type main
and press ctrl+space. The eclipse content assist will pop up with main method. Press enter.
键入main
并按ctrl+ space。eclipse内容辅助会弹出main方法。按enter。
回答by zoladp
I think the best practise is to use only keyboard. It makes workflow a lot faster.
我认为最好的做法是只使用键盘。它使工作流程更快。
- Create new java class with
Ctrl+n
- on dialog box, enter its (class) name
- use
(left)Alt+v
to easily tick checkbox for -public static void main(String[] args)
- then press
[enter]
Finish and voila class is ready...
- 创建新的java类
Ctrl+n
- 在对话框中,输入其(类)名称
- 用于
(left)Alt+v
轻松勾选复选框 -public static void main(String[] args)
- 然后按
[enter]
完成,瞧课程准备好了......