This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Java in General and the fly likes collections.remove() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "collections.remove()" Watch "collections.remove()" New topic


Amirtharaj Chinnaraj
Ranch Hand

Joined: Sep 28, 2006
Posts: 241
hi guys
i tried this code below

but i end up in exception below

i dont know the reason
looking for yopur replies
Joanne Neal

Joined: Aug 05, 2005
Posts: 3742
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

Joined: Dec 20, 2006
Posts: 89
Arrays.asList(s) returns unmodifiable collection. Therefore you need to use other collection:

Author of <a href="" target="_blank" rel="nofollow">NewsInjector</a>
I agree. Here's the link:
subject: collections.remove()
It's not a secret anymore!