Java 在三个数字中找出最大值
1 int aa1 = 11000000; 2 int aa2 = 20000; 3 int aa3 = 6000; 4 5 //第一种 6 int max = (aa1 > aa2)? aa1:aa2; 7 int max1= (max>aa3)? max : aa3; 8 9 System.out.println("max1 = "+max1); 10 11 //第二种 不建议 12 int maxx= (aa1>aa2)? ((aa1>aa3)?aa1:aa3):aa2; 13 14 System.out.println("maxx = "+maxx); 15 16 //第三种 17 if(aa1 > aa2) 18 { 19 if(aa1>aa3) 20 { 21 System.out.println("aa1="+aa1); 22 } 23 else 24 { 25 System.out.println("aa3="+aa3); 26 } 27 } 28 else if(aa2>aa3) 29 { 30 System.out.println("aa2="+aa2); 31 } 32 else 33 { 34 System.out.println("aa3 = "+aa3); 35 }
本文来自博客园,作者:Bytezero!,转载请注明原文链接:https://www.cnblogs.com/Bytezero/p/15193882.html