Hello.
As I said in the title. Imho everything should work, when I am testing it, the program show the shortest string. Can someone look at my code and try to help me understanding the problem?
package com.codegym.task.task07.task0709;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.ArrayList;
/*
Expressing ourselves more concisely
*/
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> list = new ArrayList<String>();
int min = 0;
for (int i = 0; i < 5; i++){
String s = reader.readLine();
list.add(s);
min = list.get(0).length();
if (list.get(i).length() < min)
min = list.get(i).length();
}
for (int i = 0; i < 5; i++){
if (list.get(i).length() == min){
System.out.println(list.get(i));
}
}
}
}