switch 的case没有break
时间: 2023-10-18 21:29:49 浏览: 117
在switch语句中,每个case后面可以选择性地使用break来控制程序的跳出。如果一个case没有使用break语句,那么程序将会继续执行下一个case,直到遇到break语句或者switch语句结束。这种情况下,后续的case语句将被依次执行,而不是跳过。所以,如果你希望在找到符合条件的case后就停止执行后续的case语句,你可以在找到符合条件的case后使用break来跳出switch语句。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [浅谈java switch如果case后面没有break,会出现什么情况?](https://blog.csdn.net/weixin_35149412/article/details/114560441)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [js switch case default 的用法示例介绍](https://download.csdn.net/download/weixin_38660108/13055896)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [switch...case 没有break问题](https://blog.csdn.net/rammuschow/article/details/107051105)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文