if (strings.get(j).length()>=maxLength)
{
maxLength = strings.get(j).length();
System.out.println(strings.get(j));
}
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 void main(String[] args) throws Exception
{
strings = new ArrayList<String>();
BufferedReader cbeu = new BufferedReader(new InputStreamReader(System.in));
for (int i=0; i<5; i++)
{
String a = cbeu.readLine();
strings.add(a);
}
int maxLength = 0;
for (int j=0; j<5; j++)
{
if (strings.get(j).length()>=maxLength)
{
maxLength = strings.get(j).length();
System.out.println(strings.get(j));
}
}
}
}