我有几个切换案例,如果案例1要执行,那么我需要发送带有附件的邮件,否则对于其他切换案例,只需要发送一封电子邮件。下面是我的开关cases.How如果我的case1执行了,我可以写一个if语句吗?
switch (case)
{
case assigning:
break;发布于 2019-10-17 13:28:07
只需在一个单独的变量中记住选择了哪个大小写,然后在以后使用该值:
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);
}https://stackoverflow.com/questions/58425360
复制相似问题