![]() If we want to represent a group of individual objects as a single entity where "duplicates are allow and insertion order must be preserved" then we should go for List interface.It is the child interface of Collection.There is no concrete class which implements Collection interface directly.Collection interface defines the most common methods which can be applicable for any collection object.In general we can consider collection as root interface of entire collection framework.If we want to represent a group of "individual objects" as a single entity then we should go for collection.It defines several classes and interfaces to represent a group of objects as a single entity.ĩ(Nine) key interfaces of collection framework: If we want to represent a group of objects as single entity then we should go for collections. Every collection class is implemented based on some standard data structure hence for every requirement ready-made method support is available being a programmer we can use these methods directly without writing the functionality on our own.ĭifferences between Arrays and Collections ? ArraysĢ) Memory point of view arrays are not recommended to use.Ģ) Memory point of view collections are highly recommended to use.ģ) Performance point of view arrays are recommended to use.ģ) Performance point of view collections are not recommended to use.Ĥ)Ěrrays can hold only homogeneous data type elements.Ĥ)Ĝollections can hold both homogeneous and heterogeneous elements.ĥ) There is no underlying data structure for arrays and hence there is no readymade method support.ĥ)Ğvery collection class is implemented based on some standard data structure and hence readymade method support is available.Ħ)Ěrrays can hold both primitives and object types.Ħ)Ĝollections can hold only objects but not primitives.Collections can hold both homogeneous and heterogeneous objects.Collections are growable in nature that is based on our requirement we can increase (or) decrease the size hence memory point of view collections concept is recommended to use.To overcome the above limitations we should go for collections concept. For every requirement we have to write the code explicitly. S=new Customer() //invalid(compile time error)ģ)ěut we can resolve this problem by using object type array(Object).Ĥ)Ěrrays concept is not implemented based on some data structure hence ready-made methods support we can't expert. Arrays can hold only homogeneous data elements.Arrays are fixed in size that is once we created an array there is no chance of increasing (or) decreasing the size based on our requirement hence to use arrays concept compulsory we should know the size in advance which may not possible always.So that readability of the code will be improved. The main advantage of array is we can represent huge no of elements by using single variable.An array represents a group of elements of same data type.An array is an indexed collection of fixed no of homogeneous data elements.How to get synchronized version of HashMap.Differences between HashMap and Hashtable ?.Compression of Set implemented class objects.Compression of Comparable and Comparator ?.Compression of Enumeration, Iterator and ListIterator ?. ![]() Getting synchronized version of ArrayList object.Differences between ArrayList and Vector ?.In collection framework the following are legacy characters.What is the difference between Collection and Collections ?.9(Nine) key interfaces of collection framework.Differences between Arrays and Collections ?.** * Useful utility methods for Collections Framework * * javaguides. Don't forget to check out to Useful Collections Utility Methods CollectionUtils.java package
0 Comments
Leave a Reply. |