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, 23.06.2019 03:50
Iam a bacterium. i cause stomach cramps and diarrhea. i am caused by eating rotten foodssuch as chicken, fish, or eggs. sometimes turtles carry my bacteria.what am i?
Answers: 2
question
Computers and Technology, 23.06.2019 14:30
Norder to receive financial aid at his vocational school, mario must fill out the fafsa. the fafsa is a form that must be completed to determine . in order to complete a fafsa, you must submit . the fafsa can students obtain
Answers: 2
question
Computers and Technology, 24.06.2019 00:50
Which player type acts on other players? a. killer b. achiever c. explorer d. socializer
Answers: 1
question
Computers and Technology, 24.06.2019 17:50
You work in the accounting department and have been using a network drive to post excel workbook files to your file server as you complete them. when you attempt to save a workbook file to the drive, you see the error message: β€œyou do not have access to the folder β€˜j: \’. see your administrator for access to this folder.” what should you do first
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
English, 02.07.2019 01:10
Questions on the website: 13722362