Saturday, 11 May 2013


ArrayList which i use the most .... 

Array means collection of same type of data and blah blah blah !!

you will say if there is Array then why to use ArrayList??

the basic difference between this two is Array are of fixed size Whereas an ArrayList implements the list data structure and can dynamically grow.

one more difference between Array and ArrayList is that you can create instance of ArrayList without specifying size while we have to provide size while creating instance of Array

example of Arraylist :

    ArrayList<String> countries = new ArrayList<String>();
    countries.add("India");    //This will add India to countries ArrayList
    countries.get(0);            //here you have to provide index as argument in total this line
                                        //will give you value present at that index

some other methods :

 countries.contains("India");   //returns true if argument you pass is present in list else false
 countries.clear();               //clear all the elements present in ArrayList      

for more detail visit follow link :                                    

No comments:

Post a Comment