这个方法是最佳方法
public class HelloWorld {
public static void main(String[] args) {
int[] a={99,1,2,4,8,9};
int temp=0;
int temp2 =0;
for(int i = 0; i <a.length ; i++) {
if(a[i]>temp){
temp2=temp;
temp=a[i];
}
else if (a[i]<temp&a[i]>temp2){
temp2=a[i];
}
}
System.out.println(temp2);
}}