生成局部变量以接收方法eclipse的返回值 [英] Generate local variable to receive the return value of a method eclipse
本文介绍了生成局部变量以接收方法eclipse的返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如我有这段代码
categoryCT.getInsertedItems();
我希望快捷方式生成这样的代码
and I want shortcut to generate code like this
List<Category> insertedItems= categoryCT.getInsertedItems();
推荐答案
Eclipse无法帮助您使用变量名称但是你可以写:
Eclipse can't help you with the variable name but you can write:
insertedItems = categoryCT.getInsertedItems();
这会给你一个编译错误。
This will give you a compile error.
如果在此行的任何位置按 Ctrl + 1 ,Eclipse将提供创建局部变量'insertedItems'
If you press Ctrl+1 anywhere in this line, Eclipse will offer "Create local variable 'insertedItems'"
获取最少的击键次数期望的结果:
Fewest keystrokes to get the desired result:
-
catCT
Ctrl + Space - >categoryCT
-
.getII
Ctrl + Space - >categoryCT.getInsertedItems()
-
;
- Shift + Alt + Left 选择整个方法调用
- Ctrl + 1 + select创建新的本地变量
catCT
Ctrl+Space ->categoryCT
.getII
Ctrl+Space ->categoryCT.getInsertedItems()
;
- Shift+Alt+Left to select the whole method invocation
- Ctrl+1 + select "Create new local variable"
这篇关于生成局部变量以接收方法eclipse的返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文