title: Counting array reference input and displaying count -- infinite loop
body: <p>I am trying to display the occurrence of how many times an integer occurs in an array but I get an infinite loop/logic error. For instance, if the user enters: 2, 5, 6, 5, 4, 3, 23, 43, 2, 0 then it should display:</p>
  
  <pre><code>2 occurs 2 times
  3 occurs 1 time
  4 occurs 1 time
  5 occurs 2 times
  6 occurs 1 time
  23 occurs 1 time
  43 occurs 1 time
  </code></pre>
  
  <p>Any help would really be appreciated. <em>Note: This is not an assignment or homework, It is a exercise question from intro to Java book by Y.D. Lang</em></p>
  
  <pre><code>import java.util.*;
  
  public class CountNumbers {
  
      public static void main(String[] args) {
          System.out.println("Enter the integers between 1 and 100: ");
          int[] arrayRefVar = createList();
          int[] countNum = countNumbers(arrayRefVar);
          displayCount(countNum, arrayRefVar);
      }
  
      public static int[] createList() {
          Scanner Input = new Scanner(System.in);
          int[] List = new int[100];
          int i = 0;
  
          while (List[i] != 0) {
              List[i] = Input.nextInt();
              i++;
          }
          return List;
      }
  
      public static int[] countNumbers(int[] List) {
          int[] count = new int[100];
  
          for (int i = 0; i &lt; count.length; i++) {
              count[i] = i;
          }
  
          int[] countNum = new int[List.length];
  
          for (int i = 0; i &lt; countNum.length; i++) {
              countNum[i] = 0;
          }
  
          for (int i = 0; i &lt; List.length; i++) {
              for (int j = 0; j &lt; count.length; j++) {
                  if (List[i] == count[j]) {
                      countNum[i]++;
                  }
              }
          }
          return countNum;
      }
  
      public static void displayCount(int[] countList, int[] arrayRefVar) {
          for (int i = 0; i &lt; arrayRefVar.length; i++) {
              System.out.println(arrayRefVar[i] + " occurs " + countList[i] + " " + checkPlural(arrayRefVar[i]));
          }
      }
  
      public static String checkPlural(int n) {
          if (n &gt; 1) {
              return "times";
          } else {
              return "time";
          }
      }
  }
  </code></pre>