Arrays.asList()报错unsupportedoperationexception

package org.geng.testPackage;

import java.util.ArrayList;

import java.util.Arrays;

import java.util.List;

publicclass AsListTest {

public static void main(String[] args) {

String testStr ="100,300,400,545,666";

//java.util.Arrays$ArrayList 没有重写add(), remove()方法所以用注释掉的代码会报错

//List test = Arrays.asList(testStr.split(","));

List test =new ArrayList();//所以需要这么重新new一个ArrayList

test.addAll(Arrays.asList(testStr.split(",")));

test.remove("100");

/*String s = "nu";

System.out.println(Arrays.asList(s));

*/

Integer[] payIds = {2,5,14,15};

if(Arrays.asList(payIds).contains(15)){

System.out.println("yes");

}else{

System.out.println("no");

}

}

}

你可能感兴趣的:(Arrays.asList()报错unsupportedoperationexception)