Question: Java In main: Declare an array capable of holding five Strings . Populate the array by entering five first names all on one one line

Java

In main:

  • Declare an array capable of holding five Strings.
  • Populate the array by entering five first names all on one one line separated by spaces (see sample output but use different names).
  • Use a foreach loop (see page 255) to process the array and display the names on one line separated by spaces.
  • Pass the array to a void method.

In the void method:

  • Sort the array.
  • Create an arraylist of Strings.
  • Use a loop to populate the arraylist with the Strings in the array that was passed it.
  • Insert another name (you choose it) at the start of the arraylist.
  • Remove the name at the end of the arraylist.
  • Use a foreach loop to process the arraylist and display the names on one one line separated by spaces.

Sample Output (user input in boldface) Enter five first names Penny Lenny Benny Denny Kenny Sorted array of names Benny Denny Kenny Lenny Penny Final list of names Maria Benny Denny Kenny Lenny

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!