can't pass last condition
package com.codegym.task.task07.task0718;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.*;
/*
Checking the order
*/
public class Solution
{
public static void main(String[] args) throws IOException
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String a;
ArrayList<String>list = new ArrayList<String>();
int c = 0;
//read word and add it to list:
while(true)
{
a = reader.readLine();
if(a.isEmpty()) break;
list.add(a);
c++;
}
//make new array from list for able to be sorted by Arrays.sort():
String[]arr = new String[c];
for(int i = 0; i < arr.length; i++)
{
arr[i] = list.get(i);
}
//make sort:
Arrays.sort(arr);
//compares the length of the list items and the array items:
for(int i = 0; i < list.size(); i++)
{
if(arr[i].length() < list.get(i).length())
{
System.out.println(i);
break;
}
}
}
}