-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPairTest.java
More file actions
29 lines (27 loc) · 960 Bytes
/
Copy pathPairTest.java
File metadata and controls
29 lines (27 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*------------------------------------------------------------------------------
* Oracle Certified Professional Java SE 8 Programmer Exam 1Z0-809
* A Comprehensive OCPJP 8 Certification Guide
* by SG Ganesh, Hari Kiran and Tushar Sharma
------------------------------------------------------------------------------*/
// It demonstrates the usage of generics in defining classes
class Pair<T1, T2> {
T1 object1;
T2 object2;
Pair(T1 one, T2 two) {
object1 = one;
object2 = two;
}
public T1 getFirst() {
return object1;
}
public T2 getSecond() {
return object2;
}
}
class PairTest {
public static void main(String []args) {
Pair<Integer, String> worldCup = new Pair<Integer, String>(2018, "Russia");
System.out.println("World cup " + worldCup.getFirst() +
" in " + worldCup.getSecond());
}
}