public class Demo02ScannerSum { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("請輸入第一個數字:"); int a = sc.nextInt(); System.out.println("請輸入第二個數字:"); int b = sc.nextInt(); System.out.println("請輸入第三個數字:"); int c = sc.nextInt(); int[] num = {a, b, c}; int d = num.length; int max = num[0]; for (int i = 0; i < d; i++) { if (num[i] > max) { max = num[i]; } } System.out.println("最大值為" + max);