What is the difference between google's ImmutableList and Collections.unmodifiableList ()?

后端 未结 5 1268
孤城傲影
孤城傲影 2020-12-08 02:11

From ImmutableList javadocs:

Unlike Collections.unmodifiableList(java.util.List), which is a view of a separate collection that can still change

5条回答
  •  伪装坚强ぢ
    2020-12-08 03:02

    ImmutableList is similar to Collections.unmodifiableList( new ArrayList( list ) ) . Note that the newly created ArrayList is not assigned to a field or variable.

提交回复
热议问题