why this code does not pass verification, the last two conditions?
If I add a "dog" to the list, the output is a car dog and if I add "a" the output is a .
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 {
//write your code here
ArrayList<String> list = new ArrayList<>();
BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
for(int i=0; i<5; i++){
list.add(reader.readLine());
}
list.add("dog");
list.add("a");
int sh=0;
for(int i=0; i<list.size(); i++){
sh=list.get(i).length(); // i 0
if(sh>list.get(i).length()){
sh=list.get(i).length();
}
}
for(int i=0; i<list.size(); i++){
if(list.get(i).length()==sh){
System.out.println(list.get(i));
}
}
}
}