简体   繁体   English

如何在eclipse中自动完成main()?

[英]How to auto-complete main() in eclipse?

I am using Eclipse Helios. 我正在使用Eclipse Helios。 I am wondering if there is anyway to add the main() method quickly in Eclipse? 我想知道是否还有在Eclipse中快速添加main()方法?

Type 类型

main

then your content assist shortcut key. 然后你的内容辅助快捷键。

在此输入图像描述


You can also add a main method from the class creation wizard. 您还可以从类创建向导中添加main方法。 There's a checkbox to have it put in a main method for you. 有一个复选框,可以将它放入主方法中。 rfreak - rfreak

This is just main and Ctrl+Space . 这只是主要的和Ctrl + Space

Or 要么

type ma and then press ctrl+space 键入ma然后按ctrl + space

Or 要么

type m and then press ctrl+space . 键入m然后按ctrl + space

There are two easy way to add main method in your class. 在类中添加main方法有两种简单的方法。 1. While creating class there is an option - public static void main(String[] args) option - select the check box. 1.在创建类时,有一个选项 - public static void main(String [] args)选项 - 选中复选框。

在此输入图像描述

  1. After creating class also you can add main method. 创建类后,您还可以添加main方法。 type main and press ctrl+space - the [main - main method] option will be displaying - select it. 键入main并按ctrl + space - 将显示[main - main method]选项 - 选择它。

在此输入图像描述

In Eclipse you can first type "main" then ctrl + / and it can be finished automatically. 在Eclipse中,您可以先键入“main”,然后按ctrl + / ,它可以自动完成。

And In windows Eclipse, you can type "main" , and then alt + / ,it will be finished automatically! 在windows Eclipse中,你可以输入“main”,然后输入alt + / ,它会自动完成!

I am on mac and I use TextExpander to create snippets of frequently used codes. 我在Mac上,我使用TextExpander创建常用代码的片段。 I know I am going bit off your question but I am sure this will be very helpful. 我知道我会对你的问题感到厌烦,但我相信这会非常有帮助。

You can create snippets of code and assign them keywords. 您可以创建代码片段并为其分配关键字。 This works with any programming language and in any editor. 这适用于任何编程语言和任何编辑器。 You just need to type the keyword and your snippet will be auto loaded. 您只需输入关键字,您的代码段就会自动加载。

For eg. 例如。 for my main method I have created keyword jmain . 对于我的main方法,我创建了关键字jmain So everytime I need main method I just need to type jmain and the code will be loaded. 所以每当我需要main方法时,我只需要输入jmain并加载代码。 You can also control the placement of cursor. 您还可以控制光标的位置。

截图

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM