I don't know exaclly what is wrong here. Program does show the correct solution but still sth is wrong.
package pl.codegym.task.task07.task0708;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/*
Najdłuższy ciąg
*/
public class Solution {
private static ArrayList<String> strings = new ArrayList<String>();
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for(int a = 0; a < 5; a++) {
String s = reader.readLine();
strings.add(a, null);
strings.set(a, s);
}
int longest = strings.get(0).length();
for(int a = 0; a < 5; a++) {
for(int b = a + 1; b < strings.size(); b++) {
if(longest < strings.get(b).length()) {
longest = strings.get(b).length();
}
}
}
for(int a = 0; a < 5; a++) {
if(longest == strings.get(a).length()) {
System.out.println(strings.get(a));
}
}
}
}