In the output window it shows "Grandmother" which is the longest string. I'm not sure why it's not passing the final two verifications. Your help is appreciated.
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
strings = new ArrayList<String>();
BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
for(int i = 1; i <=5; i++){
String text = read.readLine();
strings.add(text);
}
int longestString = 0;
String longestListString = null;
for (int i = 1; i < strings.size()-1; i++) {
int size = strings.get(i).length();
if (size > longestString){
longestString = size;
longestListString = strings.get(i);
}
}
System.out.println(longestListString);
}
}