【发布时间】:2015-06-24 13:53:52
【问题描述】:
我正在尝试使用要处理的切换案例来处理组合用户输入,并且在最终切换之前似乎进展顺利
System.out.println("\t output switch = " + state.get(2));
switch(state.get(2)){
//Case MCNP
case 0:
{
abundances = verifyAndNorm(abundances, new MCNPVerifier(MCNP));
out = toMCNP(mat, abundances);
System.out.println("\t MCNP");
}
//Case SCALE
case 1:
{
abundances = verifyAndNorm(abundances, new SCALEVerifier(SCALE));
out = toSCALE(mat, abundances, weightFracFlag);
System.out.println("\t SCALE");
}
}
打印出来
output switch = 0
MCNP
SCALE
结果是 out = toScale(...),因为它同时打印 MCNP 和 SCALE,所以它必须同时满足两种情况,但它只适用于一种情况...
我在这里错过了什么?
【问题讨论】:
-
这里发生了所谓的
fall-through -
在我生命周期的这一点上,我希望不要被视为初学者,谦虚但仍然不好玩。
标签: java switch-statement