求看看将数组转化为list后为什么以增添元素然后排序就报错??
import java.util.*;
import java.util.Scanner;
public class Test3 {
public static void main(String[] args) {
System.out.println("插入一个数字");
Scanner sc=new Scanner(System.in);
int nn=sc.nextInt();
Integer [] n= {9,8,7,6,5,4};
List<Integer>list=Arrays.asList(n);
list.add(nn);
for(int i=0;i<list.size();i++) {
System.out.println(list.get(i)+" ");
}
Collections.sort(list);
}
}显示Exception in thread "main" java.lang.UnsupportedOperationException
at java.base/java.util.AbstractList.add(Unknown Source)
at java.base/java.util.AbstractList.add(Unknown Source)
at Test3.main(Test3.java:10)