collections

2
Collections are used to deal with multiple objects of similar type at one point of time. ArrayList: Capacity is used to give the number of items that can be stored on the given items and it can be extended. By Default 4 items can be stored in any capacity if you don’t specify the capacity and it will double the size if you add 5 th item i.e. 8 and if you add 9 th item then it will be 16 etc.. You can also trim the size of items to specific number using TrimToSize() method. Count is used to give the number of items that are there in the current arraylist. The difference between Add and Insert in Arraylist is...in Add method we will directly give the name of the item whereas in Insert we need to specify the index and name to where we are expecting to insert.

Upload: venkat-rao

Post on 22-Dec-2015

221 views

Category:

Documents


0 download

DESCRIPTION

COLLECTIONS

TRANSCRIPT

Page 1: Collections

Collections are used to deal with multiple objects of similar type at one point of time.

ArrayList:

Capacity is used to give the number of items that can be stored on the given items and it can be extended. By Default 4 items can be stored in any capacity if you don’t specify the capacity and it will double the size if you add 5th item i.e. 8 and if you add 9th item then it will be 16 etc.. You can also trim the size of items to specific number using TrimToSize() method.

Count is used to give the number of items that are there in the current arraylist.

The difference between Add and Insert in Arraylist is...in Add method we will directly give the name of the item whereas in Insert we need to specify the index and name to where we are expecting to insert.

Page 2: Collections

HashTable:

From HashTable we get DictionaryEntry from where we can get Key and Value to iterate through all the items.

The order that we entered into the Hashtable may not return in the same order when we interate through this collection. Because does not manage the items through its index position and it uses its own algorithm.

There can be two same values with two different keys in HashTable.