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

1 Expert Approved Answer
Step: 1 Unlock

Sure heres how you can accomplish both tasks a Using a regular for loop import j... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!