It works Perfect but compiler refuses to exept my code. Please why?
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 String tempS;
public static int tempN;
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
strings = new ArrayList<>();
for (int i = 0; i < 5; i++) {
String s = reader.readLine();
strings.add(s);
}
tempN = 0;
for (int i = 0; i < strings.size()-1; i++) {
String a = strings.get(i);
int b = a.length();
if(b>tempN) {
tempS = a;
tempN = b;
}
}
ArrayList<String> list2 = new ArrayList<>();
for (int i = 0; i < strings.size(); i++) {
String x = strings.get(i);
int y = x.length();
if (y == tempN) {
list2.add(x);
}
}
for (int i = 0; i < list2.size(); i++) {
System.out.println(list2.get(i));
}
}
}