Eclipse 快捷键返回值Alt+shift+L和Ctrl+1

在Eclipse中开发时候,返回值快捷键的使用极大地提高开发的效率,而返回值的快捷键有两种:Alt+shift+L和Ctrl+1;下面简单介绍两种快捷键的使用方式。

第一种:Alt+shift+L

1、将光标放在有返回值的代码句的分号后面(放在前不行);

Eclipse 快捷键返回值Alt+shift+L和Ctrl+1

2、按住Alt+Shift+L键,会弹出对话框,输入变量的名字,点击OK即可;

Eclipse 快捷键返回值Alt+shift+L和Ctrl+1

3、返回值:类型 变量;

Eclipse 快捷键返回值Alt+shift+L和Ctrl+1

 

第二种:Ctrl+1

1、将光标放置在有返回值代码句那一行上(分号前后都行);

Eclipse 快捷键返回值Alt+shift+L和Ctrl+1

2、选择Assign statement to new local variable : 生成局部变量;

      选择Assign statement to new field : 生成全局变量;

Eclipse 快捷键返回值Alt+shift+L和Ctrl+1

Eclipse 快捷键返回值Alt+shift+L和Ctrl+1

局部变量;

Eclipse 快捷键返回值Alt+shift+L和Ctrl+1

全局变量;

Eclipse 快捷键返回值Alt+shift+L和Ctrl+1