I have tried doing it like the last problem. I can't figure out how to pass the conditions
package com.codegym.task.task07.task0709;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
/*
Longest string
*/
public class Solution {
int i;
List<String>strings = new ArrayList<String>();
Scanner sc = new Scanner(System.in);
for (int i = 0; i<5;i++)
{ String s = sc.nextLine();
strings.add(s);
}
public static void main(String[] args) {
//write your code here
for (int i = 0; i<5; i++)
{
if (strings.get(i).length() == shortestString().length())
System.out.println(strings.get(i));
}
}
public static String shortestString() {
String min = strings.get(0);
for(int j = 1; j<5; j++)
{ if (strings.get(j).length()<strings.get(0).length())
min = strings.get(j);
}
return min;
}
}