Где я выхожу за пределы списка? не понимаю..
public class Solution {
public static void main(String[] args) throws IOException {
ArrayList<Integer> List = new ArrayList<Integer>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for(int i = 0; i < 10; i++){
String zero = reader.readLine();
int number = Integer.parseInt(zero);
List.add(number);
}
int count = 1;
int count1 = 1;
for(int o = 0; o < 10; o++){
if(List.get(o).equals(List.get(o - 1))){
count++;
} if(count > count1){
count1 = count;
} else {
count = 1;
}
}
System.out.print(count1);
}
}
package com.javarush.task.task08.task0812;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.util.LinkedList;
public class Solution {
public static void main(String[] args) throws IOException {
ArrayList<Integer> List = new ArrayList<Integer>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for(int i = 0; i < 10; i++){
String zero = reader.readLine();
int number = Integer.parseInt(zero);
List.add(number);
}
int count = 1;
int count1 = 1;
for(int o = 0; o < 10; o++){
if(List.get(o).equals(List.get(o - 1))){
count++;
} if(count > count1){
count1 = count;
} else {
count = 1;
}
}
System.out.print(count1);
}
}