3 回答

TA貢獻1805條經驗 獲得超10個贊
這工作正常,請檢查您的 if 條件組合?。。?/p>
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);
}
}
添加回答
舉報