• Post Reply Bookmark Topic Watch Topic
  • New Topic

Optional methods in Collection interface  RSS feed

 
Rajiv KumarRai
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings

Please let me understand what do we mean by optional methods in Collection interface.(e.g add, addAll etc)
If we write a class that implements the Collection interface are we required to provide implementations
for the optional methods?

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sort of. You must implement them, but they can just through the UnsupportedOperationException exception.
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can extend AbstractList or similar classes.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!