Write a generic class pair which has 2 type parameters f


Exercise

Write a generic class Pair which has 2 type parameters, F and S, representing the type of the first and second elements of a pair respectively.
Add get and set methods for the first and second elements of the pair.

Override the toString() method to display the first and second values of the pair in a format of your choosing.

Use the Pair class in a program that creates an ArrayList of 10 Pair objects containing values of your choosing. The program will then print the string representation of each Pair to System.out (i.e., use the toString() method).

Take a screenshot of your output and paste it into the Word document you created for the first exercise, but place the screenshot under a header for "Exercise 2.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Write a generic class pair which has 2 type parameters f
Reference No:- TGS02381774

Now Priced at $10 (50% Discount)

Recommended (92%)

Rated (4.4/5)