Find Positive and Negative Numbers in Array Program in Java

import java.util.Scanner;
public class FindPositiveAndNegative
{

    public static void main(String[] args)
    {
        int ar[] = new int[10];
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 10; i++)
        {
            System.out.print("Enter the number ar[" + i + "]:");
            ar[i] = sc.nextInt();
        }
        System.out.println("The +ve numbers are:");
        for (int i = 0; i < 10; i++)
        {
            if (ar[i] > 0)
            {
                System.out.println(ar[i]);
            }
        }
        System.out.println("The -ve numbers are:");
        for (int i = 0; i < 10; i++)
        {
            if (ar[i] < 0)
            {
                System.out.println(ar[i]);
            }
        }
    }
}


Output:

Enter the number ar[0]:1
Enter the number ar[1]:2
Enter the number ar[2]:5
Enter the number ar[3]:-9
Enter the number ar[4]:6
Enter the number ar[5]:-5
Enter the number ar[6]:7
Enter the number ar[7]:8
Enter the number ar[8]:-9
Enter the number ar[9]:-2
The +ve numbers are:
1
2
5
6
7
8
The -ve numbers are:
-9
-5
-9
-2
java tutorials learn java study java