Is there any way to pull variable up outside try-catch block with shortcut? For example:
from:
try{
AbstractList<Type> t1 = new ArrayList<Type>();
} catch (Exception e) {
...
}
to
AbstractList<Type> t1;
try{
t1 = new ArrayList<Type>();
} catch (Exception e) {
...
}
I know how to do this with a few shortcuts:
put your cursor on t1
and then "Show intention actions". From there, select "Split into declaration and assignment". Your code will now look like this:
try {
AbstractList<String> t1;
t1 = new ArrayList<String>();
} catch (Exception e) {
e.printStackTrace();
}
Do the "move statement up" action. Now your code will look like this:
AbstractList<String> t1;
try {
t1 = new ArrayList<String>();
} catch (Exception e) {
e.printStackTrace();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With