Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autogenerate method response in Eclipse

Tags:

java

eclipse

Consider the following snippet of code

private MyOutputObject createMyOutputObject(MyInputObject myInputObject) {

}

To get rid of Eclipse's "must return a result of type..." compiler error alert, I will then add the following:

private MyOutputObject createMyOutputObject(MyInputObject myInputObject) {
    MyOutputObject myOutputObject = null;
    return myOutputObject;
}

Is there any way within Eclipse to autogenerate this response creation?

like image 924
DJ180 Avatar asked May 10 '13 18:05

DJ180


People also ask

How do I go back a call method in eclipse?

Navigating Back to a Previously Viewed Method While browsing code, you'll often want to return to the previous method you were viewing once you're done viewing the method it calls. To do this, use Alt+Left (Backward History) to move back to the last navigation point.

How do you call a method in eclipse?

by default eclipse does an exact match search, but you can use wildcards. once you see the method you're interested in, press down to select the method (if it's not selected already). press enter once the method is selected. eclipse will take you directly to the method's declaration.

How do I find the 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.


1 Answers

In Eclipse if you go to Preferences > Java > Code Style > Code Templates you will see a list of code templates. Under Code go to Method body and you can modify the generated code.

like image 195
rancidfishbreath Avatar answered Oct 14 '22 16:10

rancidfishbreath