what is java array list code example
Example 1: arraylist java
//requires either one of these two imports, both work.
import java.util.ArrayList;
//--or--
import java.util.*
ArrayList<DataType> name = new ArrayList<DataType>();
//Defining an arraylist, substitute "DataType" with an Object
//such as Integer, Double, String, etc
//the < > is required
//replace "name" with your name for the arraylist
Example 2: java arraylist
List<String> expenseTypeList = new ArrayList<>();
expenseTypeList.add("GENERAL");
expenseTypeList.add("PURCHASE");
expenseTypeList.add("PROJECT");