The output is coming correct as expected, but the task is not getting passed.
Please let me know the issue is the code and what needs to be corrected
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> ();
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader reader = new BufferedReader (new InputStreamReader(System.in));
for (int i = 0; i < 5; i++)
strings.add(reader.readLine());
int listsize = strings.size();
String longestString = strings.get(0);
for (int i = 1; i < strings.size()-1; i++)
{
String s = strings.get(i);
if (longestString.length() <= s.length()) {
System.out.println(longestString ) ;
longestString = s;
System.out.println(longestString ) ;
}
}
}
}