java arraylist method code example
Example 1: how to import an arraylist in java
import java.util.ArrayList;
Example 2: arraylist in java
import java.util.ArrayList;
public class ArrayListExample
{
public static void main(String[] args)
{
int num = 14;
ArrayList<Integer> al = new ArrayList<Integer>(num);
for(int a = 1; a <= num; a++)
{
al.add(a);
}
System.out.println(al);
al.remove(7);
System.out.println(al);
for(int a = 0; a < al.size(); a++)
{
System.out.print(al.get(a) + " ");
}
}
}
Example 3: arraylist
ArrayList<String>arrayList=new ArrayList<>();
Example 4: arraylist java methds
import java.util.ArrayList;
ArrayList<Integer> myList = new ArrayList<Integer>();
myList.add(0);
myList.remove(0);
myList.size();
myList.get(0);
Example 5: java how to create arraylist
import java.util.ArrayList;
ArrayList<String> arrayList = new ArrayList<String>();