下列代码的输出结果是_____
boolean b=true?false:true==true?false:true;
System.out.println(b);
答案:false
题目来源:携程2016研发工程师笔试题 https://www.nowcoder.com/test/1026783/summary
知识点:
- ==优先级大于?:
- ?:计算方向:从右到左
解析:
boolean b=true?false:true==true?false:true;
=boolean b=true?false:(true==true)?false:true;
=boolean b=true?false:true?false:true;
=boolean b=true?false:(true?false:true);
=boolean b=true?false:false;
=boolean b=false;