What is the use of singletonList?

前端 未结 3 1150
予麋鹿
予麋鹿 2021-01-04 11:28

I was looking around for some elegant solution to removing null values from a List. I came across the following post, which says I can use list.removeAll(Collections.

3条回答
  •  有刺的猬
    2021-01-04 11:51

    Has your list been protected with

    Collections.unmodifiableList(list)
    

    Because if you have protected it and try to modify it later you get that error.

提交回复
热议问题