add to end of arraylist java code example
Example 1: how to add to an arraylist java
import java.util.ArrayList;
public class Details {
public static void main(String[] args) {
ArrayList<String> al= new ArrayList<String>();
al.add("Ram");
al.add("Shyam");
al.add("CPS");
al.add("John");
al.add("Steve");
System.out.println("Elements of ArrayList of String Type: "+al);
Example 2: arraylist add new element to end
stringList.add(random);
stringList.add(0, random);
stringList.set(4, random);
stringList.remove(5);
stringList.clear();