Sitemap

ArrayList in Java Collection Framework.

Jul 29, 2023

--

List Interface can be implemented in Java using Different Concrete Classes Like ArrayList,LinkedList,Stack,Queue.

Lets consider ArrayList used to Implement the List Interface in Java.

ArrayList

Get Surajkh’s stories in your inbox

Join Medium for free to get updates from this writer.

ArrayList can be used for the creation of Dynamic Arrays in Java,Let us go through the below Code Snippet to consider the creation of ArrayList.

Press enter or click to view image in full size
ArrayList Creation.

Let us go through the Different Operations that can be applied on an ArrayList.

Press enter or click to view image in full size
Add,Removal Operation in ArrayList

Iterating through the Contents of the ArrayList using the concept of Iterators.

Press enter or click to view image in full size
Iterating over the ArrayList.

Sorting an ArrayList can be consider by using the Concept of Collections.sort().

Press enter or click to view image in full size
Sorting of the contents present in the ArrayList using the concept of Collections.sort().

Lets consider the Custom Sorting in ArrayList by using the Concept of Comparator Interface.

Press enter or click to view image in full size
Pair Class Definition in Java

Now lets consider the implementation of the Comparator Interface for Sorting.

Press enter or click to view image in full size
Implementation of Comparator Interface.
Press enter or click to view image in full size
Iterating over the ArrayList after Customised Sorting using Comparator Interface.

Cloning an ArrayList :

Press enter or click to view image in full size
Cloning of ArrayList

Thank You.

--

--

Surajkh
Surajkh

Written by Surajkh

0 followers

Passionate Software Developer