dcsimg
How to make an ArrayList that cannot be grown
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   shiva_prasad
Posted On:   Tuesday, May 15, 2007 07:10 AM

How to make an ArrayList object that cannot be grown

Re: How to make an ArrayList that cannot be grown

Posted By:   WarnerJan_Veldhuis  
Posted On:   Tuesday, May 15, 2007 08:34 AM

Use the original List as a parameter for this method: java.util.Collections.umodifiableList(List)

Re: How to make an ArrayList that cannot be grown

Posted By:   Anonymous  
Posted On:   Tuesday, May 15, 2007 07:24 AM

You can't do that as the purpose of the ArrayList is to make collection which grows dynamically.If you wanted to restrict adding the elements into it , you need to write your own logic like if size > limit don't add else add it to ArrayList.
instead you can use the arrays if the obects you wanted to add it in ArrayList are of same type.
About | Sitemap | Contact