0
我期待我的输入是三个字符组之一,并且需要根据它属于哪个组来决定如何处理它。我试图弄清楚如何定义一个切换多个案例来做到这一点。这是我到目前为止:在java开关中的多个参数
while(in.hasNextChar())
{
char test = in.nextChar();
List<Signal> out = new List<Signal>(0);
switch(test)
{
case '1','0','x','X':
out.add(fromString(test));
break;
case ' ','/t':
break;
default:
throw new ExceptionLogicMalformedSignal;
}
}
return out;
}
我不完全知道为什么,应该工作,但我还挺看看它是如何做。谢谢你的帮助。 –
@C.J.Coffey你的代码只是第一个有休息的案例。 – Hristo