My code does exactly as requested. Any suggestions?
package com.codegym.task.task07.task0708;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.*;
/*
Longest string
*/
public class Solution {
private static List<String> strings;
public static void main(String[] args) throws Exception {
String wow = "";
strings = new ArrayList<String>();
Scanner bol = new Scanner(System.in);
for (int x = 0; x < 5; x++) {
strings.add(bol.nextLine());
}
bol.close();
// List < String> box = new ArrayList <String>();
int max = 0;
for (int y = 0; y < strings.size()-1; y++) {
String me = strings.get(y);
String last = strings.get(4);
int link = me.length();
if (link >= max) {
wow = me;
max = link;
}
if (me.equals(last)) {
break;
}
}
for (int z = 0; z < strings.size(); z++) {
String mmm = strings.get(z);
int mmmlength = mmm.length();
if (wow.length() == mmmlength) System.out.println(mmm);
}
}
}