title: actionListener and combination of loop with if-else
body: <p>I'm working on a digital attendance system. I'm using the following code in <code>actionPerformed</code>:</p>
  
  <pre><code>    for (int i = 1; i &lt; 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);
              }
          }
  </code></pre>
  
  <p>But, during executing both the println works one after the other..</p>