package ltb6w;
import java.util.*;
import java.util.ArrayList;
public class TestInteger {
private int number;
private List<Integer> list=new ArrayList<Integer>();
Scanner sc=new Scanner(System.in);
public TestInteger() {
System.out.println("请输入10个成绩");
}
public void setSort() {
int i=0;
while (i<10) {
try {
number=sc.nextInt();
}catch(InputMismatchException e) {
System.out.println("输入的数据类型不同,注意输入整数。");
break;
}
System.out.println("第"+(i+1)+"个数:"+number);
if(number==1982) {
break;
}else if (number<0) {
System.out.println("不要输入负数");
break;
}
list.add(number);
i++;
}
System.out.println("结束,输完。");
this.getSort();
}
public void getSort() {
Collections.sort(list);
for(int j=list.size()-1;j>=0;j--) {
try {
System.out.println("成绩:["+(j+1)+"]"+list.get(j));
}catch(Exception e) {
System.out.println("数组越界异常"+e.getMessage());
}
}
}
public static void main(String[] args) {
TestInteger te=new TestInteger() ;
te.setSort();
}
}