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

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

I have this code:

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


        
17条回答
  •  旧时难觅i
    2020-11-22 08:06

    Yes, on Arrays.asList, returning a fixed-size list.

    Other than using a linked list, simply use addAll method list.

    Example:

    String idList = "123,222,333,444";
    
    List parentRecepeIdList = new ArrayList();
    
    parentRecepeIdList.addAll(Arrays.asList(idList.split(","))); 
    
    parentRecepeIdList.add("555");
    

提交回复
热议问题