Java ArrayList get Example
ArrayList class get method example. This example shows you how to use get method.
ArrayList class get method example.get(int index) Returns the element at the specified position in this list.
Here is the code
/**
* @ # Get.java
* A class repersenting use to get method of ArrayList class in java.util package
* version 14 May 2008
* author Rose India
*/
import java.util.*;
public class Get {
public static void main(String args[]) {
List arrlist = new ArrayList();
int i = 0;
String str = "Rose";
//Add the specified element to the end of this list.
arrlist.add(i);
arrlist.add(str);
arrlist.add("India");
System.out.println("Element of ArrayList on 1st position = " + arrlist.get(1));
}
} |
Output
| Element of ArrayList on 1st position = Rose |
|