I think my solution is correct, or am I not understanding this right?

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.Scanner;
/*
Checking the order
*/
public class Solution {
public static void main(String[] args) throws IOException {
//write your code here
ArrayList<String> list = new ArrayList<String>();
Scanner scan = new Scanner(System.in);
int length = 0;
boolean ordered = true;
int violator = 0;
for (int i = 0; i < 10; i++)
{
String s = scan.next();
list.add(s);
if (length <= s.length())
{
length = s.length();
}
else if (length > s.length() && ordered)
{
violator = i;
ordered = false;
//break;
}
}
if (!ordered)
{
System.out.println(list.get(violator));
}
}
}

(length <= s.length())and(length > s.length())are polar opposites and you do not need to use the second one. Logically if the first one is false then the second one is true every time (and same when 1st is true the 2nd will be false).