I want to get larget n number of elements from array. Here down is my program that prints only maximum number from array but I want to print higest 10 elements or n elements from array that depends on user how many higest number he want to print from the array.
import java.util.*;
public class anna
{
    public static void main(String[] args)
    {
        int n, max;
        Scanner s = new Scanner(System.in);
        System.out.print("Enter the number of elements in the array:");
        n = s.nextInt();
        int a[] = new int[n];
        System.out.println("Enter the elements of array:");
        for(int i = 0; i < n; i++)
        {
            a[i] = s.nextInt();
        }
        max = a[0];
        for(int i = 0; i < n; i++)
        {
            if(max < a[i])
            {
                max = a[i];
            }
        }
        System.out.println("Maximum value in the array is:"+max);
    }
}
 
     
    