gpt4 book ai didi

java - 在 Android Eclipse 中编辑代码 - 如何最好地记录/折叠结束}

转载 作者:行者123 更新时间:2023-11-29 22:19:06 24 4
gpt4 key购买 nike

我刚刚意识到在 Eclipse 中不能像 {} 那样折叠代码块。唯一可以崩溃的是整个方法

现在,如果一个方法不再适合一个屏幕,有时很难找到对应的 closing

我知道 Eclipse 中的“Expand Selection To”,但在只想隐藏一个 block 的情况下这不是最佳选择,因此只能看到其余正在处理的 block 。

例如在这样的代码中:(编辑:我使用 Eclipse Format-command 格式化示例代码,所以它至少看起来没问题)

private void myMethod(String msg) {
Boolean a = true;
Integer b = 1;
Integer justSomeCode = 1;

if (a) {
switch (b) {
case 1: {
try {
justSomeCode += justSomeCode;
} catch (Exception e) {
justSomeCode += justSomeCode;
}

}
break;

case 2: {
try {
justSomeCode += justSomeCode;
} catch (Exception e) {
justSomeCode += justSomeCode;

}

}
break;
}

justSomeCode += justSomeCode;
}

else {
justSomeCode += justSomeCode;
}

}

最佳答案

这是我的追求

private void method1() {

if (condition) {
switch (...) {
case a: {
try {
...
} catch (Exception e) {
...;
}

} /* case a */
break;

case b: {
try {
...
} catch (Exception e) {
...;
}

} /* case b */
break;
} /* switch */

....
}
} else { /* if (condition1) */
...
} /* else */

} /* method1 */

话虽如此,拥有多种方法总是比用同一种方法做所有事情更可取。

关于java - 在 Android Eclipse 中编辑代码 - 如何最好地记录/折叠结束},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7750585/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com