someone pls help, the output is correct and yet it doesn't meet the requirement.
package com.codegym.task.task07.task0712;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/*
Shortest or longest
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
List<String> list = new ArrayList<>();
int minLength = Integer.MAX_VALUE;
int minIndex = 0;
int maxLength = 0;
int maxIndex = 0;
for (int i = 0; i < 10; i++) {
String read = br.readLine();
list.add(read);
if(read.length() > maxLength) {
maxLength = read.length();
maxIndex = i;
} else if(read.length() < minLength) {
minLength = read.length();
minIndex = i;
}
}
if(minIndex < maxIndex) {
System.out.println(list.get(minIndex));
} else {
System.out.println(list.get(maxIndex));
}
}
}