获取三个数据的最大值:
class Hello2 { public static void main(String[] args) { int a = 10; int b = 20; int c = 30; int max; if (a > b){ if (a > c) { max = a; }else { max = c; } }else { if (b < c) { max = c; }else { max = b; } } System.out.println("max = " + max); } }
结果: