---
title: "关于三元运算的小练习"
author: "yufengweb"
date: "2010-09-30T10:08:40Z"
tags: []
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2010-09-30T10:08:40Z"
id: 775730
url: "https://yufengweb.iteye.com/blog/775730"
---

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

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

 

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

 

&lt;!--&lt;br /&gt; &lt;br /&gt; Code highlighting produced by Actipro CodeHighlighter (freeware)&lt;br /&gt; http://www.CodeHighlighter.com/&lt;br /&gt; &lt;br /&gt; --&gt;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 }