I have written this several ways, and each produced the results asked for, but it isn't passing the last two tests. Any feedback on why this is?
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 {
//write your code here
InputStreamReader iReader = new InputStreamReader(System.in);
BufferedReader bReader = new BufferedReader(iReader);
strings = new ArrayList<>();
int longest = 0;
// ArrayList<Integer> longestI = new ArrayList<>();
for (int i = 0; i < 5; i++) {
String thisString = bReader.readLine();
strings.add(thisString);
}
for (int i = 0; i < strings.size(); i++) {
if (strings.get(i).length() >= longest) {
longest = strings.get(i).length();
System.out.println(strings.get(i));
}
}
}
}