i am doing the coursera homework, but even i use a break in this loop, it seems not break, and i searched how to break a for loop, but i still can't understand what i do is wrong. Could some nice guys explain it to me?
for (int j = 0; j < n; j++) {
    boolean[] birthdaypeople = new boolean[n];
    int birthday = (int) (Math.random() * n);
    if (!birthdaypeople[birthday]) {
        birthdaypeople[birthday] = true;
    }
    else {
        peopleindex[j + 1]++;
        break;
}
 
     
     
    