直接实例理解

public class Test {
    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

相关文章:

  • 2022-12-23
  • 2022-01-06
  • 2021-05-19
  • 2021-11-19
  • 2021-12-17
猜你喜欢
  • 2021-12-13
  • 2021-06-28
  • 2022-12-23
  • 2021-11-16
  • 2022-12-23
  • 2021-08-30
  • 2022-02-10
相关资源
相似解决方案