WAP to find the second highest number in an array
import java.util.*;
class CT2 {
public static void main(String[] args) {
int i;
int [] arr = new int [10];
Scanner sc = new Scanner(System.in);
System.out.println("Enter 10 Numbers : ");
for(i = 0; i < arr.length; i++) {
arr[i] = sc.nextInt();
}
Arrays.sort(arr);
System.out.println("Here is the second highest number of array : " + arr[arr.length-2]);
}
}
Copy Code