wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 38087
    
  22
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: 38087
    
  22
Back to the API: It says it creates a new array. Separate objects. At least that is how I read it.
 
 
subject: Collection prob