What's the problem with this code? I can't pass the case.
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.Scanner;
/*
Shortest or longest
*/
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
Scanner in = new Scanner(System.in);
ArrayList<String> list= new ArrayList<>();
for(int i=0;i<10;i++)
{
list.add(in.nextLine());
}
ArrayList<String> minList= new ArrayList<>();
ArrayList<String> maxList= new ArrayList<>();
int min=list.get(0).length(),max=min;
int index=10;
for(int i=0;i<10;i++)
{
if(list.get(i).length()>max&&index>i) {
max = list.get(i).length();
index=i;
}
else if(list.get(i).length()<min&&index>i) {
min = list.get(i).length();
index=i;
}
}
System.out.println(list.get(index));
}
}