直接贴代码吧!记录一下
public static void main(String[] args) { int num = 4; System.out.println((num > 4) ? 99.0 : 9);//9.0 char a = 'a'; int i = 96; System.out.println(2==2?i:9.0); //96.0 System.out.println(2==2?98:a); //b System.out.println(2==2?a:i); // System.out.println(2==2?99:9.0); //99.0 System.out.println(2==2 ? 99 : 'b' ); //c }
解决方案:http://www.mamicode.com/info-detail-1010428.html