package collectionsexamples;
import java.util.ArrayList;
import java.util.Iterator;
public class ArrayListRemoveElement
{
public static void main(String[] args)
{
// #1. Instantiate ArrayList Class
ArrayList<Character> siteName = new ArrayList<Character>();
// #2. Adding Elements
siteName.add('S');
siteName.add('D');
siteName.add('E');
siteName.add('T');
siteName.add('F');
siteName.add('O');
siteName.add('R');
siteName.add('U');
siteName.add('M');
// #3. Print all Elements before Deletion
System.out.println("************** All Elements before Deletion ************");
for(Character allLetters: siteName)
{
System.out.println(allLetters);
}
// #4. Remove Element at Given Index
siteName.remove(7);
// #5. Print all Elements after Deletion
System.out.println("************** All Elements before Deletion ************");
for(Character allLetters: siteName)
{
System.out.println(allLetters);
}
}
}
👨💻 Output 👨💻