-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTuple.java
More file actions
40 lines (32 loc) · 884 Bytes
/
Copy pathTuple.java
File metadata and controls
40 lines (32 loc) · 884 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
30
31
32
33
34
35
36
37
38
39
40
package src.thinkinginjava.Generics15;
/**
* Created by Ryan on 2017/2/16.
*/
public class Tuple {
public static <A,B> TwoTuple<A,B> tuple(A a, B b) {
return new TwoTuple<A,B>(a,b);
}
static class TwoTuple<A,B> {
private A a;
private B b;
public TwoTuple(A a, B b) {
this.a = a;
this.b = b;
}
@Override
public String toString() {
return a + " " + b;
}
}
public TwoTuple<String, Integer> twoTuple() {
return new TwoTuple<>("yes", 5);
}
public TwoTuple<String, Integer> twoTupleTest() {
return new TwoTuple("src/thinkinginjava/String13", 5);
}
public static void main(String[] args) {
Tuple tuple = new Tuple();
System.out.println(tuple.twoTuple());
System.out.println(tuple.twoTupleTest());
}
}