Write a java program to check prime number

We know that a number which have only two factors one is 1 and another is number itself is call prime number.
Here examples of prime number are 2,3,5,7 and other more.
Here the jave code which find out that a given number is prime number or not a prime number.

package com.javaforecast4u;

public class test_prime
{
     public static void main(String as[])
     {
      int n=Integer.parseInt(as[0]);
      int c=0;
      for(int i=2;i<=n/2;i++)

    /* n/2 reduces the search by half since if no.
      is divisible by 1st half of the nos. then
     there is no need to divide the no. with next   1/2   or use
    */

    for(i=2;i<n;i++) 
      {
        if(n%i==0)
                c++;   
           break;
         }
     if(c>0)
           System.out.println("not prime");
          else
          System.out.println("prime");
    }
    }