Arrays.asList()报错unsupportedoper

2017-05-11  本文已影响0人  小火耳

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");

}

}

}

上一篇下一篇

猜你喜欢

热点阅读