gpt4 book ai didi

java - Intellij 检查 switch case fall-through

转载 作者:行者123 更新时间:2023-11-29 07:30:35 25 4
gpt4 key购买 nike

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/

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