Can anybody tell me what's wrong with my code? Everythings seems to be fine, program displays the longest string or many of them, but it failes last two conditions.
package com.codegym.task.task07.task0708;
import javax.swing.*;
import java.awt.*;
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 {
//write your code here
strings = new ArrayList<>();
List<String> Longest = new ArrayList<>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0; i < 5; i++) {
strings.add(reader.readLine());
}
String first = strings.get(0);
for (int i = 0; i <strings.size(); i++) {
if (first.length() <= strings.get(i).length()) Longest.add(strings.get(i));
}
Longest.forEach(System.out::println);
}
}