-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise2.java
More file actions
45 lines (38 loc) · 851 Bytes
/
Copy pathExercise2.java
File metadata and controls
45 lines (38 loc) · 851 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
41
42
43
44
45
class Pay{
private String name;
public Pay(String name){
this.name = name;
}
@Override
public String toString() {
return name;
}
}
public class Exercise2<T>{
private T a, b, c;
public Exercise2(T a, T b, T c){
this.a = a;
this.b = b;
this.c = c;
}
public void setA(T a){
this.a = a;
}
public void setB(T b){
this.b = b;
}
public void setC(T c){
this.c = c;
}
@Override
public String toString() {
return a + ", " + b +", " + c;
}
public static void main(String[] args) {
Pay a = new Pay("master card");
Pay b = new Pay("visa card");
Pay c = new Pay("verve card");
Exercise2<Pay> ex = new Exercise2<Pay>(a, b, c);
System.out.println("Output: " + ex);
}
}