Why do I get an UnsupportedOperationException when trying to remove an element from a List?

后端 未结 17 2168
后悔当初
后悔当初 2020-11-22 07:43

I have this code:

public static String SelectRandomFromTemplate(String template,int count) {
   String[] split = template.split(\"|\");
   List         


        
17条回答
  •  一个人的身影
    2020-11-22 08:10

    Arrays.asList() uses fixed size array internally.
    You can't dynamically add or remove from thisArrays.asList()

    Use this

    Arraylist narraylist=new ArrayList(Arrays.asList());
    

    In narraylist you can easily add or remove items.

提交回复
热议问题