Write a Java program that uses ArrayList and Iterator. It should input from user the names and ages of your few friends in a loop and add into ArrayList. Finally, it should use an Iterator to display the data in a proper format.
Write a Java program that uses ArrayList and Iterator. It should input from user the names and ages of your few friends in a loop and add into ArrayList. Finally, it should use an Iterator to display the data in a proper format.
( Sample run of the program:-)
List of my Friends
Enter name and age [friend# 0]
Khalid Al-shamri
22.5
Do you want to add another friend (y/n)? y
Enter name and age [friend# 1]
Rahsed Al-anazi
21.1
Do you want to add another friend (y/n)? y
Enter name and age [friend# 2]
Salem Al-mutairi
23.7
Do you want to add another friend (y/n)? n
Here is the data you entered:
0. Khalid Al-shamri, 22.5
1. Rahsed Al-anazi, 21.1
2. Salem Al-mutairi, 23.7
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images