Tried looking at the other issues people had I am not able to find the issue. Also I am receiving the right output
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 ArrayList<String> strings = new ArrayList<>();
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader j = new BufferedReader(new InputStreamReader(System.in));
for(int i = 0;i<5;i++){
strings.add(j.readLine());
}
int longestNum = 0;
for(int i = 0;i<5;i++){
if(strings.get(i).length()>longestNum){
longestNum=strings.get(i).length();
}
}
for(int i = 0;i<5;i++){
// int lengthOfString = strings.get(i).length();
if(strings.get(i).length()==longestNum){
System.out.println(strings.get(i));
}
}
}
}