title: Help trying to understand modulo operation in circular array
body: <p>i have a small issue trying to figure out how a modulo operation is being calculated.
  I am building up a queue, so i have a circular array.
  i cannot figure out how this modulo operation works.</p>
  
  <p>Given q: an array of Character of 5 elements length, 
  The MAX constant gives the max length of the array "5"
  rare is an int which represents the first available spot in the array q</p>
  
  <pre><code>    public void enqueue(Character c)throws FullQueueException{
  
      if(size()== MAX -1){ //if only 1 place left, is full, throw exc 
  
          throw new FullQueueException("Queue is full");
      }
      q[rare]=c;  
      rare=(rare+1)%MAX;
  }
  </code></pre>
  
  <p>Now, supposing that the rare "first empty spot" is three, what is the rare value going to be after the method has finished? 
  this is what i dont get, rare=(rare+1)%MAX means rare=4%5 which gives rare=0,8.</p>
  
  <p>Same for method size:</p>
  
  <pre><code>public int size() {
  
      return (MAX - front + rear) % MAX;
  }
  </code></pre>
  
  <p>Given, front, an int variable which represents the first element in the array
  Suppose front is 1 and rare 4, so there are 3 elements in the array, so size is (5-1+4)%5 which is 8%5 which gives 1.6, while the actual size is 3
  Any suggestion? this might be more math then java but probably some of you came across the same doubt before.
  Thank you!</p>