ArrayList<Integer> integerArray = new ArrayList<Integer>();
ArrayList<String> stringArray = new ArrayList<String>();
ArrayList<Double> doubleArray = new ArrayList<Double>();
//... keep replacing what is inside the <> with the appropriate
//data type
import java.util.ArrayList;
class Main {
public static void main(String[] args){
// create ArrayList
ArrayList<String> languages = new ArrayList<>();
// Add elements to ArrayList
languages.add("Java");
languages.add("Python");
languages.add("Swift");
System.out.println("ArrayList: " + languages);
}
}
//Create the Arraylist variable: . Replace the T with the type of
//data to be stored in the list.
ArrayList<T> exampleList = new ArrayList<>();
//You can now perform operations on this ArrayList
// create Integer type arraylist
ArrayList<Integer> arrayList = new ArrayList<>();
// create String type arraylist
ArrayList<String> arrayList = new ArrayList<>();