简体   繁体   English

Eclipse - 基于return或get声明变量(快捷方式)

[英]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.

相关问题 Eclipse快捷方式将变量名称声明为方法参数 - Eclipse shortcut to declare a variable name as method parameter Eclipse快捷方式自动填充有用类型的实例变量? - Eclipse shortcut to autofill a usefull type of instance variable? eclipse快捷方式将新对象分配给现有变量 - eclipse shortcut assign new object to existing variable 用于在字符串文字中插入变量的Eclipse快捷方式 - Eclipse shortcut to insert variable in string literal 如果我使用快捷方式引入变量,什么是IntelliJ IDEA快捷方式声明最终变量? - What is the IntelliJ IDEA shortcut declare a final variable if I use shortcut to introduce variable? 在eclipse中有一个生成资源的快捷方式(构造函数,get / set ......) - is there a shortcut in eclipse for generating resources (constructors , get/set …) 在Java中获取基于UTC偏移量的时区快捷方式 - Get timezone shortcut based on UTC offset in Java 从弹出窗口复制eclipse中的变量值的任何插件或快捷方式? - Any plugin or shortcut to copy variable values in eclipse from popup window? 如何获取“作为Java应用程序运行”作为Eclipse运行配置中的快捷方式 - how to get “run as java application” as a shortcut in the run configuration of eclipse 如何在Eclipse中获取没有继承的方法列表(快捷方式)? - How to get a method list in Eclipse without inherited ones (shortcut)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM