mar*_*los 11 refactoring intellij-idea
有没有办法用快捷方式将变量拉到try-catch块之外?例如:
从:
try{
AbstractList<Type> t1 = new ArrayList<Type>();
} catch (Exception e) {
...
}
Run Code Online (Sandbox Code Playgroud)
至
AbstractList<Type> t1;
try{
t1 = new ArrayList<Type>();
} catch (Exception e) {
...
}
Run Code Online (Sandbox Code Playgroud)
Dan*_*lan 15
我知道如何使用一些快捷方式:
将光标置于t1然后"显示意图操作".从那里,选择"拆分为声明和分配".您的代码现在看起来像这样:
try {
AbstractList<String> t1;
t1 = new ArrayList<String>();
} catch (Exception e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)执行"移动声明"操作.现在你的代码看起来像这样:
AbstractList<String> t1;
try {
t1 = new ArrayList<String>();
} catch (Exception e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
629 次 |
| 最近记录: |