← Back to Generics
Question 173
Build a Generic Pair Class
Build a Generic Pair Class
Complete thePair<T>class. Both fields are already declared. Add a constructor that sets them, then complete the two getter methods. IMPORTANT: Do NOT write a main method. A hidden test will createPair<Integer>andPair<Character>objects and verifygetFirst()andgetSecond()return the correct values.
Expected Output:
10 20 A B
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
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.