Хотел решить с использованием массива. Код компилируется, но после ввода чисел с клавиатуры, ругается на Инициализацию массива, в цикле for. В чем моя ошибка? P.S. Задача решена по другому
2
5
6
7
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 4 out of bounds for length 4
	at com.javarush.task.task04.task0419.Solution1.main(Solution1.java:26)

Process finished with exit code 1
package com.javarush.task.task04.task0419;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Solution1 {
        public static void main(String[] args) throws Exception {
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            String inA = reader.readLine();
            String inB = reader.readLine();
            String inC = reader.readLine();
            String inD = reader.readLine();
            int a = Integer.parseInt(inA);
            int b = Integer.parseInt(inB);
            int c = Integer.parseInt(inC);
            int d = Integer.parseInt(inD);

            int[] abcd = {a, b, c , d};

            if (a == b && b == c && c == d) {
                System.out.println(a);
            } else {
                int num = 0;
                for (int i = 0; i < 5; i++) {

                    if (num < abcd[i]) {
                        num = abcd[i];
                    }
                }
                System.out.println(num);
            }
        }
}