title: java checkerboard pattern with asterisks
body: <p>I've looked over lots of posts already and they have helped a lot, but none have covered my issue. I'm trying to print out an alternating checkerboard pattern for a class assignment. My output starting on the first line and every odd line has an extra print at the end. It should be repeating a 8x8 pattern basically. Here is my code and a screenshot of my output.    </p>
  
  <p>I need to know how to alter the code so that I only get 8 asterisks in the odd lines instead of the 9 that are showing now.</p>
  
  <pre><code>public class Checkerboard {
  
      public static void main(String[] args) {
  
          int length = 16;
          int height = 8;
  
          for (int i = 0; i &lt;= height; i++)
          {
              if (i % 2 == 0)
              {
                  System.out.print("* ");
              }
              else
              {
                  System.out.print(" ");
              }
              for (int j = 0; j &lt;= length; j++)
              {
                  if (j % 2 == 0)
                  {
                      System.out.print(" ");
                  }
                  else
                  {
                      System.out.print("* ");
                  }
              }
              System.out.println("");
          }
      }
  }
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/bUsGu.jpg" rel="nofollow">output</a></p>