这可能是重复的,但我看不出有任何关于此错误的问题,所以请道歉.
我正在尝试使用该remove()方法从我的移除整数ArrayList,但它给了我java.lang.UnsupportedOperationException.remove方法应该int对我的理解采用一个或整数,或者来自的值ArrayList,但这些似乎不起作用并给出相同的错误.
我也尝试使用"深度"作为index,因为这是index我想删除的.
这是我的代码:
import java.util.*;
public class EP{
public static List<Integer> items = Arrays.asList(12, 13, 48, 42, 38, 2827, 827, 828, 420);
public static void main(String[]args){
System.out.println("Exam List");
for(Integer i: items){
System.out.println(i);
}
Scanner scan = new Scanner(System.in);
System.out.println("Enter depth");
int depth = scan.nextInt();
System.out.println("Enter value");
int value = scan.nextInt();
System.out.println(mark(depth, value));
}
public static int mark(int depth, int value){
int ret = -1; //This …Run Code Online (Sandbox Code Playgroud)