Create a Java program that will perform the following statements. Perform the following items in a continuous manner. The code solution for the next item will be based on the code performed on the previous item. 1. Create an ArrayList named “apostles” and add the following names to it: Juan, Pedro, Lucas, Judas, Mateo, Marcos and Simon. 2. Print the size of the ArrayList to the standard output before and after adding the names. 3. Use two methods to print the names in standard output. a. Using For loop b. Using Iterator 4. Add the name “Philip” at the end, and add the name “Thomas” between the two names “Juan” and “Pedro”. 5. Remove the name “Judas” using its index position. 6. Search the names “Marcos”, “James” and “Judas” in the ArrayList “apostles” This part will display the following: Does “apostles” contains Marcos? _______ (it will return a Boolean result) Does “apostles” contains James? _______ Does “apostles” contains Judas? _______ 7. Sort the names of the ArrayList in alphabetical order. 8. Print the sorted names using the enhanced for loop.
Create a Java
Perform the following items in a continuous manner. The code solution for the next item will be based
on the code performed on the previous item.
1. Create an ArrayList named “apostles” and add the following names to it: Juan, Pedro, Lucas,
Judas, Mateo, Marcos and Simon.
2. Print the size of the ArrayList to the standard output before and after adding the names.
3. Use two methods to print the names in standard output.
a. Using For loop
b. Using Iterator
4. Add the name “Philip” at the end, and add the name “Thomas” between the two names “Juan”
and “Pedro”.
5. Remove the name “Judas” using its index position.
6. Search the names “Marcos”, “James” and “Judas” in the ArrayList “apostles”
This part will display the following:
Does “apostles” contains Marcos? _______ (it will return a Boolean result)
Does “apostles” contains James? _______
Does “apostles” contains Judas? _______
7. Sort the names of the ArrayList in alphabetical order.
8. Print the sorted names using the enhanced for loop.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images