Java ArrayList get Method Example | Java ArrayList

Following ArrayListGet method program will return the element at the specified index position from the ArrayList. ArrayList Get method has been implemented from List Interface.

Arraylistget.java

import java.util.ArrayList;

public class ArrayListGet

{

 public static void main(String[] args)
 {
  ArrayList  al = new ArrayList  ();
  al.add(23);
  al.add(47);
  al.add(72);
  al.add(10);
  al.add(7);
  al.add(92);
  al.add(58);
  al.add(69);
  al.add(92);

  System.out.println(al);
  int a = al.get(3);
  System.out.println(a);
  int b = al.get(6);
  System.out.println(b);
 }
}

Output:

[23, 47, 72, 10, 7, 92, 58, 69, 92]

10

58

Leave a Reply

Your email address will not be published. Required fields are marked *