10
Dec
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
int[] numbers={14,12,9,15,17,21,23,5,8,25};
System.out.println("Given array: "+Arrays.toString(numbers));
Arrays.sort(numbers);
System.out.println("Second largest number: "+numbers[numbers.length-2]);
System.out.println("Second smallest number: "+numbers[1]);
}
}
Output:
Given array: [14, 12, 9, 15, 17, 21, 23, 5, 8, 25]
Second largest number: 23
Second smallest number: 8
Leave a Reply