public class Demo { public static void main(String[] args){ //获取三个数的最大值 int n1 = 12; int n2 = 30; int n3 = -43; int max1=(n1>n2)?n1:n2; int max2=(max1>n3)?max1:n3; System.out.println("三个数中最大的值为"+max2); } }
public class Demo { public static void main(String[] args){ //获取三个数的最大值 int n1 = 12; int n2 = 30; int n3 = -43; int max1=(n1>n2)?n1:n2; int max2=(max1>n3)?max1:n3; System.out.println("三个数中最大的值为"+max2); } }