Виводит самую длинную строку но проверку не проходит. В чем прикол?
package com.javarush.task.task07.task0708;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Самая длинная строка
*/
public class Solution {
private static ArrayList<String> strings;
public static void main(String[] args) throws Exception {
//напишите тут ваш код
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String str1 = reader. readLine();
String str2 = reader. readLine();
String str3 = reader. readLine();
String str4 = reader. readLine();
String str5 = reader. readLine();
strings = new ArrayList<String>();
strings.add(str1);
strings.add(str2);
strings.add(str3);
strings.add(str4);
strings.add(str5);
int max = strings.get(0).length();
for (int i= 0; i<5; i++) {
if (strings.get(i).length()>max) {
max = strings.get(i).length();
if (strings.get(i).length()==max) {
System.out.println(strings.get(i));
}
}
}
}
}