Skip to content

Instantly share code, notes, and snippets.

@manjaykumardp
Created July 6, 2022 09:56
Show Gist options
  • Save manjaykumardp/75d74ec5aa74f4e3b36ddcd245476699 to your computer and use it in GitHub Desktop.
Save manjaykumardp/75d74ec5aa74f4e3b36ddcd245476699 to your computer and use it in GitHub Desktop.
program of Arraylist
import java.util.ArrayList;
public class ArrayList2 {
public static void main(String[] args) {
ArrayList<String> arrayList =new ArrayList<>();
System.out.println("Intial size of arraylist"+ arrayList.size());
arrayList.add("A");
arrayList.add("B");
arrayList.add("C");
arrayList.add("D");
System.out.println("Size of arraylist after adding eleemnt"+ arrayList.size());
System.out.println("content of arraylist"+ arrayList);
arrayList.add(2,"E");
System.out.println("changed content arraylist"+ arrayList);
arrayList.remove(3);
arrayList.remove("A");
System.out.println("changed content after removing element"+ arrayList);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment