Thompson Rivers University
Question 1
Lab 4 Collections - SM 2025Use the generic Pair class from the “Generics” PowerPoint notes to build a pair containing the two strings "Hello" and "World". In other words, write code that creates a Pair<String, String> and stores "Hello" as the first element and "World" as the second.
The generic class can hold values of different types without rewriting the class for each type. The Pair<F, S> class uses two type parameters, <F> for the first value and <S> for the second.
Members only
Keep reading this lesson
You've reached the end of the free preview. Unlock the rest of this lesson plus 54 more lessons in Thompson Rivers University.
- Unlimited coding questions
- Unlimited access to all classroom material
- Weekly live call for questions and guidance
- 3,000 AI tutor tokens / month
- Personal SQL database (3 MB)
- Progress tracking
Cancel any time.