I'm trying to build a extension of ArrayList and build a custom Iterator for it, all in generic types, and I'm getting errors before compilation which I do not understand.
public class GenerateurBiGramme <T> extends ArrayList <T> {
public Iterator<Pair<T,T>> iterator(int delta){
return new BiGramme<>(delta);
}
public class BiGramme <T> implements Iterator<Pair<T, T>>{
int premier = 0;
int dernier = 1;
int delta;
public Pair<T, T> next() {
Pair<T,T> temp = new Pair<T,T>(get(this.debut),get(this.dernier));
return temp;
}
My IDE is telling me that "Pair(T,T) in Pair cannot be applied to (T,T).
I don't understand what it means by that.
Thank you for your help!
EDIT: here is my "Pair" class:
public class Pair<T, U> {
public T premiere;
public U deuxieme;
public Pair( T premiere, U deuxieme ) {
this.premiere = premiere;
this.deuxieme = deuxieme;
}
}
Basically, I'm going to feed a table into the generator, and I intend to use "premier" and "dernier" to create pairs at a set distance from one another...
org.apache.commons.lang3.tuple.Pairor some otherPairclass? If it's your own class, can you show us the code please?BiGramme, this.debut, this.dernier...