简体   繁体   中英

How to auto-complete main() in eclipse?

I am using Eclipse Helios. I am wondering if there is anyway to add the main() method quickly in Eclipse?

Type

main

then your content assist shortcut key.

在此输入图像描述


You can also add a main method from the class creation wizard. There's a checkbox to have it put in a main method for you. rfreak

This is just main and Ctrl+Space .

Or

type ma and then press ctrl+space

Or

type m and then press ctrl+space .

There are two easy way to add main method in your class. 1. While creating class there is an option - public static void main(String[] args) option - select the check box.

在此输入图像描述

  1. After creating class also you can add main method. type main and press ctrl+space - the [main - main method] option will be displaying - select it.

在此输入图像描述

In Eclipse you can first type "main" then ctrl + / and it can be finished automatically.

And In windows Eclipse, you can type "main" , and then alt + / ,it will be finished automatically!

I am on mac and I use TextExpander to create snippets of frequently used codes. 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 . So everytime I need main method I just need to type jmain and the code will be loaded. You can also control the placement of cursor.

截图

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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