直接上代碼!復習基礎!
public static void main(String args[]){
int a , b;
a = 10;
b = (a == 1) ? 20: 30;//如果a等於1那么b就等於20,否則等於30
System.out.println( "Value of b is : " + b );
b = (a == 10) ? 20: 30;
System.out.println( "Value of b is : " + b );
}
}
打印:
Value of b is : 30
Value of b is : 20