`
yufengweb
  • 浏览: 2586 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

关于三元运算的小练习

 
阅读更多

以下三段代码的输出分别是什么?为什么会有这样的结果?

<!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> -->1 public class BoxingTest {
2 
3     public static void main(String[] args) {
4         System.out.println(true ? null : 0);
5     }
6 
7 }

 

<!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> -->1 public class BoxingTest {
2     
3     public static void main(String[] args) {
4         System.out.println(true ? (Integer) null : 0);
5     }
6     
7 }

 

<!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> -->1 public class BoxingTest {
2 
3     public static void main(String[] args) {
4         System.out.println(true ? (Integer) null : new Integer(0));
5     }
6 
7 }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics