Arrays.asList() doubt?

前端 未结 8 1257
粉色の甜心
粉色の甜心 2020-12-05 08:00

People say that asList method convert the array into list and its not copying, so every change in \'aList\' will reflect into \'a\'. So add new values in \'aLis

8条回答
  •  萌比男神i
    2020-12-05 08:54

    asList returns a fixed-size list, so that you cannot add new elements to it. Because the list it returns is really a "view" of the array it was created from ('a' in your case), it makes sense that you won't be able to add elements - just like you can't add elements to an array. See the docs for asList

提交回复
热议问题