3 回答
TA贡献1805条经验 获得超10个赞
这工作正常,请检查您的 if 条件组合!!!
public class If2 {
static boolean b1, b2;
public static void main(String[] args) {
int x = 0;
if (!b1) /* Line 7 */
{
System.out.println("1"+b1);
if (!b2) /* Line 9 */
{ System.out.println("2"+b2);
b1 = true;
System.out.println("2.1 b1 is"+b1);
x++;
if (5 > 6) {
x++;
}
System.out.println("3"+b1);
System.out.println("4"+b2);
if (!b1) /* Line 17 */ //Vipul:- as b1 is true this will not invoke
x = x + 10;
else if (b2 = true) /* Line 19 */ //Vipul:- as b2 is true this will invoke
x = x + 100;
else if (b1 | b2) /* Line 21 */
x = x + 1000;
System.out.println("X"+x);
}
}
System.out.println(x);
}
}
添加回答
举报