Longest sequence

package com.codegym.task.task08.task0812;
import java.io.*;
import java.util.ArrayList;
/*
Longest sequence
1. Create a list of numbers.
2. Use the keyboard to add 10 numbers to the list.
3. Display the length of the longest sequence of repeating numbers in the list.
Example for the list 2, 4, 4, 4, 8, 8, 4, 12, 12, 14:
3
The value is 3, because the longest sequence of repeating numbers is three fours
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> numbers = new ArrayList<>();
for ( int i=0; i<10; i++ )
{
numbers.add(Integer.parseInt(bfr.readLine()));
}
int seq=1;
int maxSeq=0;
for ( int i=0; i<numbers.size()-1; i++ )
{
if ( numbers.get(i).equals(numbers.get(i+1)))
seq++;
if ( seq>maxSeq )
maxSeq=seq;
}
System.out.println(maxSeq);
}
}

seq++, 4seq++, 8, 8,seq++, 4, 12, 12,seq++, 14 So your result is currently 5 instead of 3, i guess? To reset your seq-Counter, simply add an else-part (when the two numbers are not identical, then the currently longest sequence is broken and seq can be reset to 1).