Is the problem that I should check whether there are more than 1 shortest string, and only then put them in another list and print that list?
package com.codegym.task.task07.task0709;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Expressing ourselves more concisely
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> list = new ArrayList<>();
ArrayList<String> shortList = new ArrayList<>();
int shortest = 0;
for (int i = 0; i < 5; i++) {
list.add(br.readLine());
}
for(int i = 0; i < list.size(); i++) {
for (int j = 0; j < list.size(); j++) {
if (list.get(i).length() < list.get(j).length()) {
shortest = list.get(i).length();
}
}
}
for (int i = 0; i < list.size(); i++) {
if (list.get(i).length() == shortest) {
shortList.add(list.get(i));
}
}
for (int i = 0; i < shortList.size(); i++) {
System.out.println(shortList.get(i));
}
}
}