Strange UnsupportedOperationException when calling list.remove(0)

后端 未结 5 1475
故里飘歌
故里飘歌 2021-01-23 17:04

I have this method which takes a varargs of Strings, creates a List out of it, and then tries to remove the first element of the list.

public void importFrom(Str         


        
5条回答
  •  一向
    一向 (楼主)
    2021-01-23 17:26

    Arrays.asList provides a List view of the array, BACKED by the array. And arrays are not resizable. Any attempt to change its size will throw an exception.

提交回复
热议问题