I created a generic collection class called Pair
public class Pair<L,R> {
private L l;
private R r;
public Pair(L l, R r){
this.l = l;
this.r = r;
}
public L getL(){
return l;
}
public R getR(){
return r;
}
public void setL(L l){
this.l = l;
}
public void setR(R r){
this.r = r;
}
}
I want to then create a Vector named records of type
Pair<String, int>
so that I can later iterate through the vector and compare the int values at different indexes of the vector. I did this through the following code:
private Vector<Pair<String, Long>> records = new Vector();
And then want to compare the int values at different indexes in a sorting function
public void sort(){
int n = records.size();
int p = 0;
int i, j;
for(p = 0; p < n-1; p++){
j = p;
for(i = p+1; i<n; i++){
if(records.get(i) < records.get(j))
j = i;
}
}
}
I'm getting an error in the If statement, saying that the operator is undefined for argument types. If anyone has any idea how to resolve this, please let me know. Thanks in advance