📅  最后修改于: 2022-03-11 14:52:37.794000             🧑  作者: Mango
import java.util.*;
public class GFG {
public static void main(String[] args)
{
// creating an Empty Integer List
List arr = new ArrayList(4);
// using add() to initialize values
// [10, 20, 30, 40]
arr.add(10);
arr.add(20);
arr.add(30);
arr.add(40);
System.out.println("List: " + arr);
// element at index 2
int element = arr.get(2);
System.out.println("The element at index 2 is " + element);
}
}