Java Collection : ArrayList - Exercises and Solution
1. Write a Java program to create a new array list, add some
elements and print out the collection
Output
[Apple, Banana, Cherry, Pineapple, Guava, Papaya, Plum]
2. Write a Java program to insert an element into the array
list at the first position
3. Write a Java program to remove the fifth element from a
array list
4. Write a Java program to sort a given array list
5. Write a Java program to shuffle elements in a array list
6. Write a Java program to increase the size of an array list
7. Write a Java program to reverse elements in a array list
8. Write a Java program to compare two array lists
9. Write a Java program to swap two elements in an array
list
10. Write a Java program to join two array lists
11. Write a Java program to empty an array list
12. Write a Java program to retrieve an element from a given
array list
13. Write a Java program to update specific array element by
given element
14. Write a Java program to search an element in a array list
15. Write a Java program to copy one array list into another
Note that the [Link]() method requires that the destination list (arr_List2 in this case) be at
least as large as the source list (arr_List1 in this case). If the destination list is smaller than the source
list, an IndexOutOfBoundsException will be thrown.
16. Write a Java program to extract a portion of a array list
17. Write a Java program to clone an array list to another
array list
18. Write a Java program to test an array list is empty or not
19. Write a Java program to trim the capacity of an array list
the current list size
20. Write a Java program to print all the elements of a Array
List using the position of the elements
21. Write a Java program to Find maximum element in
ArrayList
22. Write a Java program to Find minimum element in
ArrayList
23. Write a Java program to ArrayList of user defined objects
24. Write a Java program to Searching for elements in an
ArrayList
25. Write a Java program how do you find the number
of elements present in an ArrayList
26. Write a Java program decrease the current capacity of an
ArrayList to the current size
Output
27.
sdfsfsf