Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

collections.remove()

 
Amirtharaj Chinnaraj
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys
i tried this code below



but i end up in exception below



i dont know the reason
looking for yopur replies
amir
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is optional for a class that implements the Collection interface to allow objects to be the removed. If it doesn't want to allow objects to be removed, then it's implementation of the remove method should just throw an UnsupportedOperationException. Obviously the object that Arrays.asList returns has chosen to do this.
[ April 24, 2008: Message edited by: Joanne Neal ]
 
Vilmantas Baranauskas
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arrays.asList(s) returns unmodifiable collection. Therefore you need to use other collection:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic