易错题

public class Test01
{
  public static void main(String[] args) 
  {
     char x = 'x';
     int i = 10;
     System.out.println(false ? i : x);        // 120
     System.out.println(false ? 10 : x);     // x
  }
}
总结:由于后面是i为int,将char转换为int;而10为常量并且可以被char类型表示,所以不会进行转换。
原文地址:https://www.cnblogs.com/echo-ling/p/6220035.html