This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt in list created by Arrays.asList( ) method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt in list created by Arrays.asList( ) method" Watch "Doubt in list created by Arrays.asList( ) method" New topic
Author

Doubt in list created by Arrays.asList( ) method

neha verma
Ranch Hand

Joined: Jun 17, 2007
Posts: 37
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.


Neha Verma
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

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.


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
neha verma
Ranch Hand

Joined: Jun 17, 2007
Posts: 37
Thanks a lot
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Doubt in list created by Arrays.asList( ) method
 
It's not a secret anymore!