Find Prime Numbers

Given a list of numbers the task is to search and print only the Prime Numbers existing in the list.

Prime Number is a number which is only divisible by 1 and the number itself i.e., it has no factors other than 1 and itself.

Example 1: 7 is only divisible by 1 and itself only. Hence it is a Prime Number.

Example 2: 4 is divisible by 1 and 2 and 4. Hence it is not a Prime Number.

Java
import java.util.*;
public class PrimeSearch
{
    public static void main(String args[])
    {
        int n=0,count=0,size=0;
        Scanner sc=new Scanner(System.in);
        System.out.print("Enter a size: ");
        size=sc.nextInt();
        int ar[]=new int[size];
        System.out.println("Enter "+size+" numbers:-");
        for(int i=0;i<size;i++)
        {
            ar[i]=sc.nextInt();
        }
        System.out.println("Prime numbers are:- ");
        for(int i=0;i<size;i++)
        {
            n=ar[i];
            for(int j=1;j<=n;j++)
            {
                if(n%j==0)
                {
                    count++;
                }
            }
            if(count==2)
            {
                System.out.println(ar[i]);
            }
            count=0;
        }
    }
}
Java