(ternary operator)三元运算符.

ternary operator:

  advantage:

    make a terse simple conditional assignment statement of if-then-else.

  disadvantage:

    if must contains return type,for instance,the code below compiles error.

1 int a = 2 > 1 ? Print.println("2 > 1") : 1;
2 //compile error.

 

posted @ 2014-03-04 00:32  wonkju  阅读(170)  评论(0编辑  收藏  举报