CJCoding With Joseph
15free / daySign inCreate account

The generic class Pair<A, B> holds two values that may be of different types, so it declares two type parameters. The fields, the constructor and both getters are written. Complete toString().

Requirements: 1. toString() returns the two values inside round brackets, separated by a comma and one space. A pair holding Ana and 90 gives (Ana, 90). 2. Build the text from the fields first and second. The same method must work for every pair of types.

Do NOT write a main method.

Expected output

(Ana, 90)
(2.5, true)
Ana

= newline. The output ends with a newline, so print one after the last line.

Hints3 available
Topics
GenericsClasses
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your output

Run your code to see the output here...

Test cases

Run your code to see test case results.