直接上代码!复习基础!
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
时间: 2024-11-09 01:56:34