← Back to Classes
Question 174
Create a Key Value Pair Class
Create a Key Value Pair Class
Complete theKeyValuePair<K, V>class. The fields are already declared. Add a constructor and complete the two getter methods. This class uses two independent type parameters — K for the key type and V for the value type. IMPORTANT: Do NOT write a main method. A hidden test will createKeyValuePair<String, Integer>andKeyValuePair<String, String>objects and verify the getters return the correct values.
Expected Output:
Joseph 95 Math A
= 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.