Getting “main” java.lang.UnsupportedOperationException

前端 未结 1 1836
深忆病人
深忆病人 2020-12-12 07:36

On executing this code, I am getting a java.lang.UnsupportedOperationException on line 81. I know posting entire code is against bet practices, but I thought it would be qu

相关标签:
1条回答
  • 2020-12-12 08:07
      Arrays.asList(tempArr)
    

    returns a fixed-size list backed by that array. You cannot remove elements from (or add elements to) it.

    Note that the list returned by Arrays.asList remains backed by that array, so that when you update elements in the list, it will change them in the array as well.

    If you need a modifiable copy, use

    new ArrayList(Arrays.asList(tempArr))
    
    0 讨论(0)
提交回复
热议问题