如何控制如下代码满足某个条件时终止当前输出public void onEvent(EventSource eventSource, String id, String type, String data) { log.info("消息

动态 未结 0 90
小小草
小小草 LV1 2023年9月23日 23:40 发表
可以在方法的开头加入判断条件,如果满足条件则直接返回,不再执行后续代码。例如: public void onEvent(EventSource eventSource, String id, String type, String data) { if (someCondition) { return; } log.info("消息结束!~"); } 其中,someCondition是你需要判断的条件,如果满足该条件,则直接返回,不再执行后续代码。
收藏(0)  分享
相关标签: 智能问答
问题没解决?让AI助手帮你作答 AI助手
0个回复
  • 消灭零回复