код вроде выполняет все условия, но говорит что четвертое условия не выполнено
package com.javarush.task.task08.task0812;
import java.io.IOException;
import java.util.*;
/*
Cамая длинная последовательность
*/
public class Solution {
public static void main(String[] args) throws IOException {
Scanner reader = new Scanner(System.in);
List<Integer> mainList = new LinkedList<>();
for (int i = 0; i < 10; i++) {
mainList.add(reader.nextInt());
}
int count1 = 1, count2 = 0;
for (int j = 1; j < mainList.size(); j++) {
if (mainList.get(j - 1).equals(mainList.get(j))) count1++;
else {
count2 = count1 > count2 ? count1 : count2;
count1 = 1;
}
}
count2 = count1 > count2 ? count1 : count2;
System.out.println(count2);
}
}