title: printing distinct numbers java
body: <p>I am having a hard time with this code. The code is finished but the output is wrong.
  My code prints Enter ten numbers: 1 2 3 5 6 6 8 7 4 1
  It should print 
  The distinct numbers are: 
  1 2 3 5 6 8 7 4 
  but it doesn't. It prints:
  10 10 10 10 10 7
  How can I fix it?
  <div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>Here is my code:
  
      import java.util.*;
      
      public class homework1 {
              public static void main(String[] args){
                      // input from user
                      Scanner input = new Scanner(System.in);
                      int [] numbers = new int[10];
                      boolean[] distinct = new boolean[10];
                      System.out.println("Enter ten numbers");
                      for (int i=0; i&lt;numbers.length; i++){
                              System.out.println("Number " + (i + 1) +":  ");
                              numbers [i] = input.nextInt();
                              distinct[i] = true;
                              for(int j = 0;j&lt;10; j++){
                                      if(numbers[i] == numbers[j] &amp;&amp; i != j) {
                                              distinct[i] = false;
                                              }
                                      }
                              }
      
                      int count=0;
                      for(int j = 0;j&lt;10; j++){
                           if (distinct[j]){
                                numbers[count]=distinct.length;
                                count++;
                           }
                      }
                      System.out.println("The number of distinct number is: "+numbers[count]);
                      System.out.println("The distinct numbers are: ");
                      for(int i= 0; i &lt; 10; i++) {
                              if(distinct[i]) {
                                      System.out.print(numbers[i] + " ");
                                      }
                              }
                              System.out.println();
              }
      }</code></pre>
  </div>
  </div>
  </p>