public class Solution {
private static List<String> strings;
public static void main(String[] args) throws Exception {
//write your code here
strings = new ArrayList<String>();
int max = 0;
Scanner sc = new Scanner(System.in);
for (int y = 0; y < 5; y++){
String a = sc.next();
strings.add(a);
}
max = strings.get(0).length();
for (int x = 0; x < strings.size(); x++){
if (strings.get(x).length() > max)
max = strings.get(x).length();
}
for (int i = 0; i < 5; i++){
if (max == strings.get(i).length())
System.out.println(strings.get(i));
}
}
package com.codegym.task.task07.task0708;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/*
Longest string
*/
public class Solution {
private static List<String> strings;
public static void main(String[] args) throws Exception {
//write your code here
strings = new ArrayList<String>();
int max = 0;
Scanner sc = new Scanner(System.in);
for (int y = 0; y < 5; y++){
String a = sc.next();
strings.add(a);
}
max = strings.get(0).length();
for (int x = 0; x < strings.size(); x++){
if (strings.get(x).length() >= max)
max = strings.get(x).length();
}
for (int i = 0; i < 5; i++){
if (max == strings.get(i).length())
System.out.println(strings.get(i));
}
}
}