How to make a copy of ArrayList object which is type of List?

后端 未结 3 1756
日久生厌
日久生厌 2020-12-20 18:18

I studied Java is pass object reference by value, and in order to make a local copy of an object, I can either do clone() or copy-constructor. I also looked at deep/shallow

3条回答
  •  隐瞒了意图╮
    2020-12-20 19:13

    It seems by question that you want to make your collection unmodified so you can use Collections.unmodifiableList().

提交回复
热议问题