|
- Prerequisites Before you begin this exercise, you need mastery of the following: Be able to define generic functions and classes in Java. Be able to follow good Java programming practices. Be able to use an integrated development environment for Java application development.
|
Sample output:
- Download the Pair.java file.
- To do:
- In Pair.java, modify the Pair class definition so that it will have two generic member variables, the key and the value.
- Modify the staticPrint method so that it will take two arguments of the two generic types same as the two generic types declared in the Pair class definition.
- Construct Pair 1 and Pair 2 using the variables given in Pair.java, and print them out using instancePrint and staticPrint.
- Demo the output to the TA
instancePrint -- key: 123, value: 456
staticPrint -- key: 123, value: 456
instancePrint -- key: Apple, value: 2.4
staticPrint -- key: Apple, value: 2.4
instancePrint -- key: 4200, value: Thu Apr 07 11:05:28 HKT 2016
staticPrint -- key: 4200, value: Thu Apr 07 11:05:28 HKT 2016