gpt4 book ai didi

java - 如果我的情况1在java中执行,我想写if语句

转载 作者:行者123 更新时间:2023-11-30 05:26:44 25 4
gpt4 key购买 nike

我有几个开关案例,如果要执行案例 1,那么我需要发送带有附件的邮件,否则对于其他开关案例,只需发送一封电子邮件。下面是我的 switch 案例。如果我的 case1 执行,我如何编写 if 语句。

switch (case) 
{
case assigning:

break;


最佳答案

只需记住在一个单独的变量中选择了哪种情况,然后使用该值即可:

boolean needAttachment = false;
switch (os)
{
case ASSIGN_TO_ADMIN:
// other stuff
needAttachment = true;
break;
// other cases, where attachment is not sent
}
if (needAttachment)
{
sendEmailWithAttachment(toList, ccList);
} else {
sendEmailWithoutAttachment(toList, ccList);
}

关于java - 如果我的情况1在java中执行,我想写if语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58425360/

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