Не проходит проверку по последнему условию. В чем загвоздка?
package com.javarush.task.task04.task0419;
/*
Максимум четырех чисел
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int a = Integer.parseInt(reader.readLine());
int b = Integer.parseInt(reader.readLine());
int c = Integer.parseInt(reader.readLine());
int d = Integer.parseInt(reader.readLine());
sort_array(a, b, c, d); }
public static void sort_array(int a, int b, int c, int d) {
int[] arr = new int[]{a, b, c, d};
int max = arr[0];
for (int i = 0; i < arr.length - 1; i++) {
if (arr[i + 1] > arr[i]) max = arr[i + 1];
}
System.out.println(max); }
}