简体   繁体   English

如何让Eclipse自动生成新Java类的main方法?

[英]How do you get Eclipse to auto-generate a main method for a new Java class?

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? 我该怎么做才能让它自动出现?

Type main and press ctrl + space . 键入main并按ctrl + space The eclipse content assist will pop up with main method. eclipse内容辅助将弹出main方法。 Press enter . enter键

"what can i do to make it appear automatically? " “我能做些什么让它自动出现?”

  • Go to create New Java Class dialog 转到创建“新建Java类”对话框
  • See a part that says "Which method stubs would you like to create?" 请参阅“您想要创建哪种方法存根?”的部分。
  • check public static void main(String[] args) 检查public static void main(String[] args)

在此输入图像描述

I think the best practise is to use only keyboard. 我认为最好的做法是只使用键盘。 It makes workflow a lot faster. 它使工作流程更快。

  1. Create new java class with Ctrl+n 使用Ctrl+n创建新的java类
  2. on dialog box, enter its (class) name 在对话框中,输入其(类)名称
  3. use (left)Alt+v to easily tick checkbox for - public static void main(String[] args) 使用(left)Alt+v轻松勾选复选框 - public static void main(String[] args)
  4. then press [enter] Finish and voila class is ready... 然后按[enter]完成并且瞧瞧类准备好了......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Eclipse可以在方法末尾自动生成Java注释吗? - Can Eclipse auto-generate Java comments at the end of a method? Java接口-自动生成方法的实现(可选地限于Eclipse) - Java Interface - Auto-generate method implementation (optionally limited to Eclipse) java:如何为变量自动生成自定义方法 - java: how to auto-generate a custom method for a variable 如何自动生成Java文件? - How to auto-generate Java files? 在eclipse中自动生成界面 - Auto-generate Interface in eclipse 无法使用Eclipse自动生成equals方法 - Can't auto-generate an equals method with eclipse 在Eclipse中自动生成类层次结构和代码结构 - Auto-generate class hierarchy and code structure in Eclipse Eclipse Java部署:如何将自动生成的文件添加到Jar文件 - Eclipse Java Deployment: how to add auto-generate file to Jar file 我如何告诉Eclipse启动时自动生成或保留存根,并进行干净的构建? - How do I tell eclipse to auto-generate or retain stubs when it starts and does a clean build? Eclipse:在项目的构建路径中编辑属于jar的任何.class文件,并自动生成与这些编辑相对应的新类文件 - Eclipse: Edit any .class file belonging to the jars in a project's build path and auto-generate a new class file corresponding to these edits
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM