If a randomly generated number is called once, how can I exclude it so it isn't called next time?
Please run my code:
HTML Code:package teacher; public class Driver { public static void main(String[] args) { Class x = new Class(); x.matrix(); } }HTML Code:package teacher; import java.util.Random; public class Class { int i, j; boolean [][] s = new boolean[6][6]; Random r = new Random(); { s[0][0] = false; s[0][1] = true; s[0][2] = false; s[0][3] = true; s[0][4] = false; s[0][5] = false; s[1][0] = false; s[1][1] = true; s[1][2] = false; s[1][3] = false; s[1][4] = false; s[1][5] = true; s[2][0] = true; s[2][1] = false; s[2][2] = true; s[2][3] = true; s[2][4] = true; s[2][5] = true; s[3][0] = true; s[3][1] = false; s[3][2] = true; s[3][3] = false; s[3][4] = false; s[3][5] = true; s[4][0] = false; s[4][1] = true; s[4][2] = false; s[4][3] = true; s[4][4] = true; s[4][5] = true; s[5][0] = false; s[5][1] = true; s[5][2] = true; s[5][3] = false; s[5][4] = true; s[5][5] = false; } public Class(){} public void matrix(){ for(j=0;j<6;j++){ i = r.nextInt(6); while(s[i][j] = true){ if(i == 0){ System.out.println((j+1) + " period: Teach kindergarden."); //this line is supposed to remove 0 from the generator } if(i == 1){ System.out.println((j+1) + " period: Teach " + i + "st grade."); //this line is supposed to remove 1 from the generator } if(i == 2){ System.out.println((j+1) + " period: Teach " + i + "nd grade."); //this line is supposed to remove 2 from the generator } if(i == 3){ System.out.println((j+1) + " period: Teach " + i + "rd grade."); //this line is supposed to remove 3 from the generator } if(i == 4){ System.out.println((j+1) + " period: Teach " + i + "th grade."); //this line is supposed to remove 4 from the generator } if(i == 5){ System.out.println((j+1) + " period: Teach " + i + "th grade."); //this line is supposed to remove 5 from the generator } else{} break; } } } }