• Post Reply Bookmark Topic Watch Topic
  • New Topic

Unmodifiable ArrayList

 
francis varkey
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
How to create UnmodifiableArrayList without using the method unmodifiableList. ?

Thanks
Francis
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first question coming to mind is why you don't want to use the Collections#unmodifiableList ? You can still look at the JDK sources, and see how it's done there. (basically, implementing List, wrapping a List which will contain the items, and throwing UnsupportedOperationException for methods trying to modify the list).

You are aware that objects inside the list can still be modified, aren't you ?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!