I can't figure out what the problem is someone please help. The program is supposed to find the index of the duplicate values in the array and print these out. Outputs java.lang.ArrayIndexOutOfBoundsException: 10.
private static String s = "";
private static int num = 0;
public static void main(String[] args) {
int[] array = { 1, 5, 3, 8, 2, 3, 7, 1, 9, 3 };
for (int i = 1; i <= array.length; ++i) {
while (num <= array.length - 2 && array[num] == array[i]) {
s += i + ",";
num += 1;
}
}
System.out.println("index 0 are at positions" +s);
System.out.println();
}