subject

To help manage the wizarding world, we need to write a merge method. For the general purpose, let us write a generic merge method. Namely, given two arrays of T objects, for example, Hogwarts students, the merge method would use stacks to merge these two T objects in the way specified in the above mentioned description and return a new ArrayList with these T objects in a special order.

The generic method prototype is as follows:

public ArrayList merge(T[] wizards1, T[] wizards2) throws Exception;

To help reverse Hogwarts students' names, we can invoke the method as follows:

merge({2, 4, 1}, {5, 7, 3})

where {2, 4, 1}, {5, 7, 3} is two array inputs and it will return an java. util. ArrayList instance, containing {1, 3, 4, 2, 7, 5}

Please use Stacks to implement the generic reverse method:

public ArrayList merge(T[] wizards1, T[] wizards2) throws Exception;

Task 2. (12 points)

Please write a test block of code by calling the method and handling the possible exception, where a String array is declared and initialized, invoke the merge method that you define and implement in the task 1. Since the merge method could throw an exception instance, we also need to write a try-catch block in order to handle the exception.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 05:00
This program will store roster and rating information for a soccer team. coaches rate players during tryouts to ensure a balanced team. (1) prompt the user to input five pairs of numbers: a player's jersey number (0 - 99) and the player's rating (1 - 9). store the jersey numbers in one int vector and the ratings in another int vector. output these vectors (i.e., output the roster). (3 pts) ex: enter player 1's jersey number: 84 enter player 1's rating: 7 enter player 2's jersey number: 23 enter player 2's rating: 4 enter player 3's jersey number: 4 enter player 3's rating: 5 enter player 4's jersey number: 30 enter player 4's rating: 2
Answers: 1
question
Computers and Technology, 23.06.2019 08:00
Match the items with their respective descriptions.
Answers: 1
question
Computers and Technology, 23.06.2019 18:40
Johnson enterprises uses a computer to handle its sales invoices. lately, business has been so good that it takes an extra 3 hours per night, plus every third saturday, to keep up with the volume of sales invoices. management is considering updating its computer with a faster model that would eliminate all of the overtime processing.
Answers: 2
question
Computers and Technology, 24.06.2019 00:40
To maintain clarity and focus lighting might be needed
Answers: 2
You know the right answer?
To help manage the wizarding world, we need to write a merge method. For the general purpose, let us...
Questions
question
Health, 05.05.2021 03:10
question
English, 05.05.2021 03:10
question
Mathematics, 05.05.2021 03:10
question
Mathematics, 05.05.2021 03:10
question
Mathematics, 05.05.2021 03:10
Questions on the website: 13722367