java - Intellij 检查 switch case fall-through

标签 java intellij-idea switch-statement

Intellij IDEA 是否检查了由于忘记了 break 而在 switch 语句中可能无意中掉线?

最佳答案

是的,确实如此:

switch

Reports 'fall-through' in a switch statement. Fall-through is defined to occur when a series of executable statements after a switch label is not guaranteed to transfer control before the next switch label. In that case, control falls through to the statements after that switch label, even though the switch expression does not equal the value of the fallen-through label. While occasionally intended, this construction is confusing, and is often the result of a typo.

请注意,此检查默认情况下处于禁用状态,因此如果您想使用它,请勾选右侧的复选框。

关于java - Intellij 检查 switch case fall-through,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43395722/

相关文章:

java - Java中的递归排列产生错误的结果

Java 与 Maven : How to make Module B depend on jar of module A?

java - 如何修复操作 switch 语句

java - 在 while 循环中使用 switch case

java - 如何在 Javascript 弹出窗口中输入凭据?我们无法传递链接中的凭据

java - 具有 DVD_START_DT 和 DVD_END_DT 覆盖的彭博 API DVD_HIST 请求

java - 我无法将 bean 引用给客户端拦截器

java - Intellij 中的故障排除 "UNRESOLVED DEPENDENCIES"

java - 如何让 "Migrate to JUnit 5"选项出现在 Intellij IDEA 中?

c++ - 使用 or 的 switch 语句