[英]Eclipse - Declare variable based on return or get (Shortcut)
I'm not sure how to phrase this in a search, however I was curious if there's a shortcut in eclipse to allow us to declare a variable type based on what's after the equal. 我不确定如何在搜索中表达这一点,但是我很好奇是否在eclipse中有一个快捷方式允许我们根据等于之后的内容声明一个变量类型。
For example: 例如:
firstname = User.getFirstName();
The minute you press enter , it would add "String" to the beginning of the line so it becomes: 按Enter键的那一刻,它会在行的开头添加“String”,使其变为:
String firstname = User.getFirstName();
Or even a shortcut key would suffice. 甚至快捷键也足够了。
There are times when a class name might be long, or something like: Iterator<Entry<String, String>>
which is long enough that a shortcut or auto add would be handy. 有时候类名可能很长,或类似:
Iterator<Entry<String, String>>
,这足够长,快捷方式或自动添加会很方便。
I'm not sure if this exists though. 我不确定这是否存在。
Thanks guys. 多谢你们。
I usually just write the expression: 我通常只写下表达式:
User.getFirstName()
Then highlight it and press Ctrl-2 , then L for "assign to local variable". 然后突出显示它并按Ctrl-2 ,然后按L以“分配给局部变量”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.