Ok, so it looks like my brain's processing power can only amount to this much. My code runs but it can only accurately calculate the first instance or occurrence of numbers in sequence e.g 1234556789 but will go very wrong when another set of number sequence show up on the list. I know I'm missing a lot of parts on this code but I just couldn't figure it out.
Can any good sir please point me to the right direction?
package com.codegym.task.task08.task0812;
import java.io.*;
import java.util.ArrayList;
/*
Longest sequence
*/
public class Solution {
public static void main(String[] args) throws IOException {
//write your code here
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < 10; i++){
list.add(Integer.parseInt(reader.readLine()));
}
Integer counter = 0;
//Integer temp = null;
for (int x = 0; x < list.size()-1; x++){
if ((list.get(x)).equals(list.get(x + 1))) {
counter++;
//temp = list.get(x);
}
}
System.out.println(counter+1);
}
}