• Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt in list created by Arrays.asList( ) method  RSS feed

 
neha verma
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When we write Arrays.asList(arr) we create a list. So cant we add anything to this list. Please see the example below. it gives me a runtime exception.Can somebody clarify.
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you read the API documentation carefully, the asList() methods returns a fixed-size List. Hence, adding an element into a List is not allowed.
 
neha verma
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!