Вроде условия задачи выполняет, но п.3 не проходит. Тестил с а, бб, ссс и т.д. печатает самую длинную строку. Почему??? Помогите)
package com.javarush.task.task07.task0712;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Самые-самые
*/
public class Solution {
public static void main(String[] args) throws IOException {
ArrayList<String>list = new ArrayList<>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int min = Integer.MAX_VALUE;
int max = 0;
int minIndex = 0;
int maxIndex = 0;
for(int i = 0; i<10; i++){
list.add(reader.readLine());
if (list.get(i).length() > max)
{max = list.get(i).length();
maxIndex = i;}
else if (list.get(i).length() < min)
{min = list.get(i).length();
minIndex = i;}
else;}
System.out.println(list.get(maxIndex<minIndex?maxIndex:minIndex));
}
}