Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA - JAVA - JAVA - JAVA Write a generic class Pair which has two type parametersF and S, each representing the type of the

JAVA - JAVA - JAVA - JAVA

image text in transcribed

Write a generic class Pair which has two type parametersF and S, each representing the type of the first and second element of the pair, respectively. Add get and set methods for the first and second elements of the pair. (Hint: The class header should be public class Pair.] Overload generic method printArray in LAB4 folder so that it takes two additional integer arguments, lowSubscript and highSubscript. A call to this method prints only the designated portion of the array. Validate lowSubscript and highSubscript. If either is out of range, or if highSubscript is less than or equal to lowSubscript, the overloaded printArray method should throw an InvalidSubscriptException; otherwise, printArray should return the number of elements printed. Then modify main to exercise both versions of printArray on arrays integerArray, doubleArray and characterArray. Test all capabilities of both versions of printArray. Overload generic method printArray in LAB4 folder with a non-generic version that specifically prints an array of strings in neat, tabular format, as shown in the sample output that follows: Array stringArray contains: three four five six seven eight one two

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is problem escalation?

Answered: 1 week ago