the program works perfect but the task failed idk why
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
{
ArrayList<String> list = new ArrayList<>();
Scanner input = new Scanner(System.in);
for(int i=1;i<=10;i++)
{
list.add(input.next());
}
int shortest=1;
for (int j = 0; j < 10; j++)
{
if (list.get(j).length() < shortest)
shortest = list.get(j).length();
}
int longest = 0;
for (int j = 0; j < 10; j++)
{
if (list.get(j).length() > longest)
longest = list.get(j).length();
}
for(int j=0;j<9;j++)
{
if((list.get(j).length() == shortest)&&(list.get(j+1).length()==longest)) {
System.out.println(list.get(j));
break;
}
else if ((list.get(j).length() == longest)&&(list.get(j+1).length()==shortest)) {
System.out.println(list.get(j));
break;
}
}
}
}