examples of Array List in java programming


Array List:

  • Fast iteration and fast Random Access.
  • It is an ordered collection (by index) and not sorted.
  • It implements the Random Access Interface.


public class Fruits{
public static void main (String [ ] args){
ArrayList <String>names=new ArrayList <String>();
names.add (“apple”);
names.add (“cherry”);
names.add (“kiwi”);
names.add (“banana”);
names.add (“cherry”);
System.out.println (names);


[Apple, cherry, kiwi, banana, cherry]

From the output, Array List maintains the insertion order and it accepts the duplicates. But it’s not sorted.

All Contributions

total contributions (0)

New to examplegeek.com?

Join us