title: Output amount of primes in array
body: <p>I'm kind of a newbie at Java, and not very good at it.  It's a trial and error process for me.</p>
  
  <p>I'm working on a Java program to output the amount of primes in an array.  I can get it to output the primes, but I want to also output the quantity of primes.  I tried to add each prime to an array list titled "primes" then return "primes.size()" at the end of my program.  It doesn't work as intended. The count is actually off.  When I create an array of 5 numbers, it outputs 3 primes, 2, 3, and 5.  But then it says I have 4 primes.  I think it might be counting 1 as a prime.   Because when I create an array of 20, the prime numbers output 2,3,5,7,11,13,17 and 19.  Then it says the total prime numbers = 9.  It should be 8 though.  </p>
  
  <p>Here's my code</p>
  
  <pre><code>public class Prime {
      public static void main(String[] args) {
          int index = 0;
          Scanner scan = new Scanner(System. in );
          System.out.println("How big would you like the array? ");
          int num = scan.nextInt();
          int[] array = new int[num];
          ArrayList &lt; Integer &gt; primes = new ArrayList &lt; Integer &gt; ();
  
          //System.out.println("How Many threads? ");
          //int nThreads = scan.nextInt();  // Create variable 'n'  to handle whatever integer the user specifies.  nextInt() is used for the scanner to expect and Int.
  
          //Thread[] thread = new Thread[nThreads];     
          for (int n = 1; n &lt;= array.length; n++) {
              boolean prime = true;
  
              for (int j = 2; j &lt; n; j++) {
                  if (n % j == 0) {
                      prime = false;
                      break;
                  }
              }
  
              if (prime) {
                  primes.add(n);
              }
  
              if (prime &amp;&amp; n != 1) {
  
                  System.out.println(n + "");
              }
  
          }
          System.out.println("Total Prime numbers = " + primes.size());
          System.out.println("Prime Numbers within " + array.length);
      }
  }
  </code></pre>
  
  <p>Forgive the sloppiness of it. I actually plan on adding multithreading to it, but I wanted to get this down first.  </p>
  
  <p>Any help would be greatly appreciated. Thanks.</p>