The results is fine but there are an failure on last 2 tasks. Can somebody tell me whats wrong? please
package pl.codegym.task.task07.task0708;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/*
Najdłuższy ciąg
*/
public class Solution {
private static List<String> strings;
public static void main(String[] args) throws Exception {
strings = new ArrayList<String>();
BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
int max=0;
for (int i=0; i<5;i++)
{
strings.add(rd.readLine());
if (strings.get(i).length()>strings.get(max).length())
max = i;
if (!strings.get(i).equals(strings.get(max)) && strings.get(i).length()==strings.get(max).length())
System.out.println(strings.get(i));
}
System.out.println(strings.get(max));
}
}