关于三元运算的小练习
以下三段代码的输出分别是什么?为什么会有这样的结果?
<!--<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 }