arraylist java code example

Example 1: how to import an arraylist in java

import java.util.ArrayList;

Example 2: arraylist java methds

import java.util.ArrayList;
ArrayList<Integer> myList = new ArrayList<Integer>();
myList.add(0);
myList.remove(0);//Remove at index 0
myList.size();
myList.get(0);//Return element at index 0

Example 3: java how to create arraylist

import java.util.ArrayList;
//create ArrayList
ArrayList<String> arrayList = new ArrayList<String>();

Example 4: java arraylist

List<String> expenseTypeList = new ArrayList<>();
        expenseTypeList.add("GENERAL");
        expenseTypeList.add("PURCHASE");
        expenseTypeList.add("PROJECT");

Example 5: arraylist in java

Size is dynamic
Only supports objects
not syncronized
array based class

Example 6: js arraylist

var array = [];

array.push(value);

Tags:

Java Example