Reputation: 9031
Does anybody know of a short cut in Eclipse that will put in the class and variable based on a method return type?
For e.g.
SomeClass{
public AnotherClass getAnotherClass(){
}
}
MainClass{
someClassObj.getAnotherClass();// Short cut here to insert "AnotherClass anotherClass ="
}
Upvotes: 3
Views: 5318
Reputation: 5491
This shortcut exists: CTRL + 2 and then a second key press:
Upvotes: 14
Reputation: 1327784
I don't think there is one, considering:
it is generally considered "bad practice" to call a method returning a value without assigning this value to a variable.
And if you assign it, you have your AnotherClass anotherClass[=...]
set in the code directly ;)
Even if you don't assign to a return value, you can move your mouse over the method to get its definition (including the return type).
Upvotes: 1