package com.sbs.java8.praticse;
public class SecondHightestClass {
public static void main(String[] args) {
final Integer[] intArray = { 10, 2, 36, 7, 29, 30, 100, 20, 90, 83, 87 };
final int n = intArray.length;
int sortPointer = intArray.length;
for (int m = n; m > (n - sortPointer); m--) {
for (int i = 0; i < n - 1; i++) {
int j = i + 1;
if (intArray[i] > intArray[j]) {
int temp = intArray[i];
intArray[i] = intArray[j];
intArray[j] = temp;
}
}
sortPointer--;
}
System.out.println(intArray[n - 2]);
}
}
Comments
Post a Comment