Difference between ArrayList and Collection
Collection:
Collection col = new ArrayList();
Iterator col_iter = col.iterator();
- You will not able to get the arraylist value by its index. (col_iter.get(index) method does not exist).
- Set firstSet = new HashSet();
You can able to assign the col_iter = firstSet; without any casting.
ArrayList:
ArrayList al = new ArrayList();
Iterator al_iter = al.iterator();
- You can access the arraylist value by its index. (al_iter.get(index) method helps to get the value by its index).
- Set secondSet = new HashSet();
You must do casting to assign set to arraylist
col_iter = (ArrayList)secondSet;
Thanks for reading this post……………!!!