Object Arrays and Collections

What are limitations of object Arrays?

The main limitations of Object arrays are

  • These are fixed in size i.e. once we created an array object there is no chance of increasing or decreasing size based on our requirement. Hence  If we donít know size in advance, arrays are not recommended to use.
  • Arrays can hold only homogeneous elements. 
  • There is no underlying data structure for arrays and hence no readymade method support for arrays. Hence for every requirement programmer has to code explicitly.
To over come these problems, collections are recommended to use.
 

What are differences between arrays and collections?
 
Arrays  Collections
1. Arrays are fixed in size and hence once we created an array we are not allowed to increase or decrease the size based on our requirement. Collections are growable in nature and hence based on our requirement we can increase or decrease the size.
2. Memory point of view arrays are not recommended to use. Memory point of view collections are recommended to use.
3. Performance point of view arrays are recommended to use. Performance point of view collections are not recommended to use.
4. Arrays can hold only homogeneous elements. Collections can hold both homogeneous and heterogeneous elements.
5. Arrays can hold both primitives as well as objects. Collections can hold only objects.
6. For any requirement, there is no ready method support compulsory programmer has to code explicitly. For every requirement ready made method support is available. Being a programmer we have to know how to use those methods and we are not responsible to implement those.

What  is  Java  Arrays?

See also
Java Arrays

Do you have a Java Problem?
Ask It in The Java Forum

Java Books
Java Certification, Programming, JavaBean and Object Oriented Reference Books

Return to : Java Programming Hints and Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.