-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathPair.java
More file actions
39 lines (30 loc) · 722 Bytes
/
Pair.java
File metadata and controls
39 lines (30 loc) · 722 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
package Pair;
/**
* You need to store two values of type `E`, set them in a constructor, and have the following methods,
* getFirst
* getSecond
* min -> returns the minimum of the pair
* max -> returns the maximum of the pair
*/
public class Pair<E extends Comparable> {
private E first;
private E second;
public Pair(E first, E second){
this.first = first;
this.second = second;
}
public E getFirst(){
return first;
}
public E getSecond(){
return second;
}
public E min(){
if(first.compareTo(second)>0);
return first;
}
public E max(){
if(first.compareTo(second)>0);
return second;
}
}