📅  最后修改于: 2022-03-11 14:52:39.705000             🧑  作者: Mango
//The add(int index, E element) method of Java ArrayList class
//inserts a specific element in a specific index of ArrayList.
//It shifts the element of indicated
//index if exist and subsequent elements to the right.
List colors = new ArrayList<>();
colors.add("red"); // ["red"]
colors.add("blue"); // ["red" , "blue"]
colors.add(1, "white"); // ["red" , "white", "blue"]
colors.add(0, "black"); // ["black", "red" , "white", "blue"]