title: Fill array with odd numbers
body: <p>I have to fill an array with a range (here <code>n</code>) of odd numbers: 1,3,5,7,9... But I always have a 0 between each odd numbers and I don't understand why.</p>
  
  <p>Note: The code under the capital letters in comments were given by our professor...</p>
  
  <p>Here is the code:</p>
  
  <pre><code>public class F5B1 {
  
      public static java.util.Scanner scanner = new java.util.Scanner(System.in);
  
      public static void main(String[] args) {
  
          // Creation of Array : DON'T CHANGE THIS PART OF THE PROGRAM.
          System.out.print("Entrez n : ");
          int n = scanner.nextInt();
          int[] t = new int[n];
          int i;
  
  
          // fill the array : PART OF THE PROGRAM TO FULFILL
          // INSTRUCTIONS :
          // ADD NO ADDITIONAL VARIABLES
          // DON'T USE ANY OF THE MATH METHODS
          // DON'T ADD ANY METHODS
  
          // I wrote this piece of code
          for (i = 0; i &lt; t.length; i++) {
              if (i % 2 != 0) {
                  t[i] += i;
              }
          }
  
          // display of the array : DON'T CHANGE THIS PART OF THE PROGRAM
  
          System.out.println("Those are the odd numbers : ");
          for (i = 0; i &lt; t.length; i++) {
              System.out.println(t[i]);
          }
      }
  
  }
  </code></pre>
  
  <p>The output:</p>
  
  <pre><code>Enter n : 10
  Those are the odd numbers : 
  0
  1
  0
  3
  0
  5
  0
  7
  0
  9
  </code></pre>