UnsupportedOperationException at java.util.AbstractList.add

前端 未结 6 1993
误落风尘
误落风尘 2020-12-07 23:51

I\'m having issues getting a block of code to run properly. I\'m not entirely sure WHAT this code does (I\'m trying to get a plugin that\'s out of date to work properly with

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 00:26

    I think I've worked out your problem. Arrays.asList(item.getStock()) returns a fixed size list based on the Array passed to it.

    This means you cannot add more elements to it.

    Instead you should do new ArrayList(Arrays.asList(item.getStock())).

    This way you are creating a new list that you can add to.

提交回复
热议问题