Question: Given the following array: import java.util.*; String[] fruits = {Apple, Mango, Pear, Banana, Cherry}; a. Write a for loop to loop through the array and
Given the following array:
import java.util.*;
String[] fruits = {"Apple", "Mango", "Pear", "Banana", "Cherry"};
a. Write a for loop to loop through the array and print out each fruit on a separate line in an ascending order. b. Write a for-each loop to loop through the array and print out each fruit on a separate line in an ascending order.
Step by Step Solution
There are 3 Steps involved in it
Sure heres how you can accomplish both tasks a Using a regular for loop import j... View full answer
Get step-by-step solutions from verified subject matter experts
