to store n number of data we can use arrays. but there are some problem in array: 1-array is a fixed length 2-type is defined and fixed and we can not store different data types. 3-the operations like insertion and deletion are very difficult.
java provides Collection interface. Collection is an interface in java.util package
collection has 4 sub interfaces:
1-set: set has 2 classes hash set and linked hash set.
2-List{Array list, linked list, stack, vector}
3-Queue
4-map{hash table, hash map}
set is an interface. we can add different type of objects to it. 1-set doesn't support duplicate Values. 2-the size of set is not fixed. 3-while storing, set does not store the data in same order in which we have provided. hash set support null for example hs.add(null) 4-set has 2 differents implemented class one is hash set and another is linked hash set. hash set: is support all feature of the set. it stores the data in array format. LinkedHashset: it support the feature of set but it stores the data in same order how it was been provided. it stores data in the format of link list.
فریبا
سهشنبه 17 مردادماه سال 1391 ساعت 01:41 ق.ظ