->An array is an indexed collection of fixed no of homogeneous data element.
Limitations of Object array:
-> Arrays are fixed in size i.e Once we created an array there is no chance for changing(increasing or decreasing) the size,Here use arrays Concept compulsory we should know the size in advance.
->can hold only homogeneous data elements
Declaretion[] S = new Declaretion[1000];
S[0] =new Declaretion[];
S[1] =new Declaretion[];
// S[2] =new Student[]; //error
-> But we can resolve this problem by using Object type arrays.
Object[] o = new Object[1000];
a[0]=new Student[];
a[1]=new Customer[];
->Arrays concept not built based on some data Structure,Hence Readmit method support is not available.
Advantages of Collections over arrays:
1) Collections are grow able in nature.Hence We can increase or decrease the size.
2) Collections can hold both Homogeneous or Heterogeneous objects.
3) Every Collection class is implemented based on some data structureHence Readmit methods avilable for every requirement.
Disadvantages of Collections:
Performance point of view collections are not recommended to use.
Difference between Arrays and Collections:
Collection :
A group of individual objects into a single entity is called "Collection".
Collection Framework:
It defines several Interfaces and classes, which can be used to represent a group of objects as a single entity.
Terminology:
Limitations of Object array:
-> Arrays are fixed in size i.e Once we created an array there is no chance for changing(increasing or decreasing) the size,Here use arrays Concept compulsory we should know the size in advance.
->can hold only homogeneous data elements
Declaretion[] S = new Declaretion[1000];
S[0] =new Declaretion[];
S[1] =new Declaretion[];
// S[2] =new Student[]; //error
-> But we can resolve this problem by using Object type arrays.
Object[] o = new Object[1000];
a[0]=new Student[];
a[1]=new Customer[];
->Arrays concept not built based on some data Structure,Hence Readmit method support is not available.
Advantages of Collections over arrays:
1) Collections are grow able in nature.Hence We can increase or decrease the size.
2) Collections can hold both Homogeneous or Heterogeneous objects.
3) Every Collection class is implemented based on some data structureHence Readmit methods avilable for every requirement.
Disadvantages of Collections:
Performance point of view collections are not recommended to use.
Difference between Arrays and Collections:
ARRAYS | COLLECTIONS |
1) Arrays are fixed in size | 1)Collections are grow able in nature |
2)Memory point of view Arrays concept is not recommended to use | 2)Highly recommended to use |
3) Performance point of view highly recommended | 3)Not Recommended |
4) Hold Homogeneous data elements | 4)Hold Homogeneous and Heterogeneous objects |
5)Readmit methods not available | 5)Readmit methods available. |
6)Arrays are used to hold both Primitives & Objects | 6)Hold only objects but not for Primitives |
Collection :
A group of individual objects into a single entity is called "Collection".
Collection Framework:
It defines several Interfaces and classes, which can be used to represent a group of objects as a single entity.
Terminology:
JAVA | C++ |
Collections | Container |
Collection Framework | STL (Standard Tamplate Library) |
9-Key interfaces of Collection Framework:
1. Collection (interface)
2. List (interface)
3. Set (interface)
4. SortedSet (i)
5. NavigableSet (i)
6. Queue (i)
7. Map (i)
8. SortedMap (i)
9. NavigableMap (i)
No comments :
Post a Comment