add to list in java code example
Example 1: java insert into arraylist
ArrayList<Integer> str=new ArrayList<Integer>();
str.add(0);
str.add(1);
str.add(1, 11);
Example 2: java append to list
package com.journaldev.examples;
import java.util.ArrayList;
import java.util.List;
public class ListAddExamples {
public static void main(String[] args) {
List<String> vowels = new ArrayList<>();
vowels.add("A");
vowels.add("E");
vowels.add("U");
System.out.println(vowels);
vowels.add(2, "I");
vowels.add(3, "O");
System.out.println(vowels);
}
}
Example 3: arraylist add method
public void add(int index, E element)