ITeye博客

关于三元运算的小练习

yufengweb · 2010-09-30 10:08 · 编程语言 · Markdown

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

<!--<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 }

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。