my dog learned polymorphism*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Collection prob 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 "Collection prob" Watch "Collection prob" New topic
Author

Collection prob

Debajit Paul
Greenhorn

Joined: Mar 27, 2008
Posts: 12
add operation is not supported why in case of a List converted from an array?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39877
    
  28
Presumably the idea is to maintain a List which mimics the array. You can probably set elements, but can't add them.

Have you read the API documentation for java.util.Arrays#asList? It says changes "write through," so you would overflow the size of the array.
Debajit Paul
Greenhorn

Joined: Mar 27, 2008
Posts: 12
when we convert list to an array....we can perform add operation on the list and it can overflow the size of the array but in case of array to list why can't we perform add operation on the list?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39877
    
  28
Back to the API: It says it creates a new array. Separate objects. At least that is how I read it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Collection prob