0
これを実行して、同じ番号の最長シーケンスを出力するようにしています。私が得るエラーは、それがクラスまたは列挙型が予想されることを私に伝えることです。ここに私のコードです:配列リストの中で最も長い配列番号
public class D4 {
private static int getLongestRun(int[] array) {
int count = 1;
int max = 1;
for (int i = 1; i < array.length; i++) {
if (array[i] == array[i - 1]) {
count++;
}
else {
count = 1;
}
if (count > max) {
max = count;
}
}
}
public static void main(String[] args) {
int[] array = new int[]{5, 6, 6, 45, 2, 2, 2};
System.out.println(getLongestRun(array));
}
}