I have spent over a day on this particular problem and I can't find out what I should do. This is the closest I have gotten to a workable solution. Can someone please help me?
package com.codegym.task.task07.task0709;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.lang.Math.*;
/*
Expressing ourselves more concisely
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> list = new ArrayList<String>();
for (int i = 0; i < 5; i++) {
String s = reader.readLine();
list.add(s);
if(list.get(i).length() > list.get(0).length())
System.out.println(list.get(i - 1));
}
}
}