title: Accept nth number of element into array and sum all the prime number which is into the array?
body: <p>In this code user enter nth number of element which combination of all prime or not prime but I want to add or sum of only prime number...</p>
  
  <pre><code>public class prime {
  
      public static void main(String[] args) {
          // TODO Auto-generated method stub
          Scanner in = new Scanner(System.in);
          System.out.println("enter the size of an array");
          int abc = in.nextInt();
          int num[] = new int[abc];
          int a = 0, sum = 0;
  
          for (int k = 0; k &lt; num.length; k++) {
              System.out.println("enter the value" + (k + 1));
              num[k] = in.nextInt();
          }
  
          for (int i = 0; i &lt; num.length - 1; i++) {
              for (int j = 2; j &lt; i; j++) {
                  if (num[i] % i == 0) {
                      a = 1;
                      break;
                  }
              }
              if (a == 0) {
                  sum = sum + i;
              }
          }
          System.out.println("number is prime" + sum);
      }
  }
  </code></pre>