How do you find second highest number in an integer array? [duplicate]
问题 This question already has answers here : Finding the second highest number in array (39 answers) Closed 5 years ago . How do you find second highest number in an integer array? Is this a good implementation? Is there a better way to do this? public class Find2ndHighest { public static void main(String[] args) { int b[] = {2,3,1,0,5}; TreeMap<Integer,Integer> tree = new TreeMap<Integer,Integer>(); for(int i = 0; i<b.length;i++){ tree.put(b[i], 0); } System.out.println(tree.floorKey(tree