title: Java bulb switch problem
body: <p>I have an array list containing 5 bulbs. I can iterate throuh them like this</p>
  
  <pre><code>for(Bulb bul : list){
      System.out.println(bul.id);
  }
  </code></pre>
  
  <p>No a bulb is switched off/on. The effect is that its neighbourg bulbs a switch too. </p>
  
  <p>My problem is that when the last or 4th bulb are switched I need to determine its neighbours. Since I have 5 bulbs this would work.</p>
  
  <pre><code>int bulbIdClicked = 3;
  
  if(bul.id == (bulbIdClicked + 1)%5)
  
  if(bul.id == (bulbIdClicked - 1)%5)
  </code></pre>
  
  <p>For 3 it would give me 2 and 4 as neighbours. But when 4 is switched it gives me 3 and 0 ans neighbours where 0 should be 5. </p>
  
  <p>How can I solve that problem?</p>