public static void main(String[] args) throws Exception {
//write your code here
BufferedReader reader = new BufferedReader ( new InputStreamReader ( System.in ) );
for (int a = 0;a < 5;a++) {
strings.add ( reader.readLine () );
}
int max = strings.get ( 0 ).length ();
for (int a = 1;a < 5;a++){
if(strings.get ( a ).length () > max){
max = strings.get ( a ).length ();
}
}
for (int a = 0;a <= strings.size ();a++){
if(strings.get ( a ).length () == max) {
System.out.println ( strings.get ( a ) );
}
}
}
}
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 = new ArrayList<String> ( );
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader reader = new BufferedReader ( new InputStreamReader ( System.in ) );
for (int a = 0;a < 5;a++) {
strings.add ( reader.readLine () );
}
int max = strings.get ( 0 ).length ();
for (int a = 1;a < 5;a++){
if(strings.get ( a ).length () > max){
max = strings.get ( a ).length ();
}
}
for (int a = 0;a <= strings.size ();a++){
if(strings.get ( a ).length () == max) {
System.out.println ( strings.get ( a ) );
}
}
}
}