So, in IDE it works just fine and returns the longest strings, but for some reason when i try to validate it fails.
Can someone let me know what i am missing here?
Many thanks
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 = new ArrayList<String>();
private static int max;
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0; i < 5; i++){
String s = input.readLine();
strings.add(s);
}
max = strings.get(0).length();
for (int i = 1; i < strings.size(); i++){
if (max < strings.get(i).length())
max = strings.get(i).length();
}
for (int i = 0; i < strings.size(); i++){
if (max == strings.get(i).length()){
System.out.println(strings.get(i));
}
}
}
}