Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shortcut to create a method stub in eclipse

Tags:

I think some shortcut to create a method stub in eclipse might be useful. Does anyone know how to do it?

like image 376
Abhijeet Kashnia Avatar asked Mar 26 '10 08:03

Abhijeet Kashnia


People also ask

How do I create a method in Eclipse?

Move the cursor beneath the main method, and enter the word private to make display a private method. Then, press Ctrl-Space to open code assist, as shown in Figure 3-8. Select the private static method item, and code assist will create the method template for you, as shown in Figure 3-9.

What is the shortcut for main method in Eclipse?

To get public static void main(String[] args) line in eclipse without typing the whole line type main and press Ctrl + space then, you will get the option for the main method select it.

How do I create a shortcut in Eclipse?

Display and Edit the Current Keyboard Shortcuts To see the current key configuration and its keyboard shortcuts, choose the Eclipse > Preferences menu command to open the Eclipse workbench Preferences. Select the General > Editor > Keys page.

What are method stubs in Eclipse?

You have the option to have Eclipse generate method stubs (a method stub is a method which is defined but has no statements in it, or no functionality) for various types of methods.


2 Answers

Type public_method (see Java/Editor/Templates in preferences for more options) or method name and press ctrl+space.

like image 182
Ha. Avatar answered Sep 21 '22 01:09

Ha.


In Addtion to the accepted answer: Typing pu for a public method (with returntype and name)is enough:

Type pu and then hit CTRL + SPACE and then ENTER.

like image 42
alexander Avatar answered Sep 21 '22 01:09

alexander