The output is correct. But the last two tasks don't pass. What is wrong?
package com.codegym.task.task07.task0708;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/*
Longest string
*/
public class Solution {
private static List<String> strings;
public static void main(String[] args) throws Exception {
strings = new ArrayList<>();
BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
int longest = 0;
for (int i = 0; i <5; i++){
strings.add(br.readLine());
}
for (int i =0; i<5; i++){
longest = strings.get(0).length();
if (strings.get(i).length()>longest){
longest=strings.get(i).length();
}
}
for (int i=0; i<5; i++){
if (strings.get(i).length()==longest)
System.out.println(strings.get(i));
}//write your code here
}
}