xxxxxxxxxx
import java.util.ArrayList;
public class MyArrayListExample {
public static void main(String[] args) {
// Create an ArrayList of strings
ArrayList<String> myList = new ArrayList<>();
// Add elements to the ArrayList
myList.add("Apple");
myList.add("Banana");
myList.add("Cherry");
// Print the elements
for (String fruit : myList) {
System.out.println(fruit);
}
}
}