I'm a beginner and working on a digital attendance system. I'm using the following code in actionPerformed:
for (int i = 1; i < count; i ++) {
if (ae.getSource () == buttons[i]) {
switch (available[i]) {
case 1: {
available[i] = 0;
names.remove (unames[i]);
System.out.println ("removing " + unames[i]);
break;
}
case 0: {
available[i] = 1;
names.add (unames[i]);
System.out.println ("at A adding" + unames[i]);
break;
}
default: System.out.println ("Default");
}
//System.out.println (names);
}
}
But, everytime the loop runs when I click a button, both the cases are executing..