Reputation: 181
This is my class (it contain a lot more methode but for the problem its enough):
public class EntrepotChaineeImpl<T extends NombreExemplaires> implements EntrepotTda<T> {
private Node<T> head;
private Node<T> tail;
private int places;
private int maxPlaces;
public EntrepotChaineeImpl(int nbPlacesMaximum) {
// TODO Auto-generated constructor stub
head= null;
tail = null;
this.maxPlaces = maxPlaces;
places= 0;
}
@Override
public Iterateur<T> iterator() {
// TODO
return new Iterateur();
}
private final class Iterateur<T extends NombreExemplaires> implements Iterator<T>{
private Node<T> aNode;
public Iterateur(){
aNode = head; //<---THE ERROR
}
@Override
public boolean hasNext() {
// TODO Auto-generated method stub
return false;
}
@Override
public T next() {
// TODO Auto-generated method stub
return null;
}
@Override
public void remove() {
// TODO Auto-generated method stub
Iterator.super.remove();
}
}
The problem is, i get this error on the constructor of Iterrateur: Type mismatch: cannot convert from Node T extends NombreExemplaires to Node T extends NombreExemplaires
I realy dont see why. thx for the help
Upvotes: 0
Views: 61
Reputation: 178263
Your inner class Iterateur
is not static
, which means that type parameters declared on the enclosing class EntrepotChaineeImpl
(T
) are in scope.
You don't need to re-declare T
on Iterateur
; this defines another T
that is different from EntrepotChaineeImpl
's T
. Because T
is still in scope, you can just use it in the implements
clause.
private final class Iterateur implements Iterator<T>{
Upvotes: 1
Reputation: 198043
private final class Iterateur<T extends NombreExemplaires> implements Iterator<T>{
should be
private final class Iterateur implements Iterator<T>{
Right now you have two different type variables named T
, one shadowing the other.
Upvotes: 1