T
Twisted
This code is part of an inner class for a custom collection class. The
parent class contains an instance member called "inner" of type Map<T,
Integer> and has a type parameter (T).
private class Iterator<T> implements java.util.Iterator<T> {
private java.util.Iterator<Map.Entry<T, Integer>> i;
Iterator () {
i = inner.entrySet().iterator();
}
public T next () {
Map.Entry<T, Integer> entry = i.next();
}
}
That's what I have so far and it complains about the constructor's only
line of code:
Type mismatch: cannot convert from Iterator<Map.Entry<T,Integer>> to
Iterator<Map.Entry<T,
Integer>>
In other words, cannot convert from foo to foo. Yes. The types are the
same. The iterator() call on the entrySet() return value returns a
java.util.Iterator<Map.Entry<T, Integer>>; the instance variable i is
explicitly declared as being of this same type.
Now what do I do?
parent class contains an instance member called "inner" of type Map<T,
Integer> and has a type parameter (T).
private class Iterator<T> implements java.util.Iterator<T> {
private java.util.Iterator<Map.Entry<T, Integer>> i;
Iterator () {
i = inner.entrySet().iterator();
}
public T next () {
Map.Entry<T, Integer> entry = i.next();
}
}
That's what I have so far and it complains about the constructor's only
line of code:
Type mismatch: cannot convert from Iterator<Map.Entry<T,Integer>> to
Iterator<Map.Entry<T,
Integer>>
In other words, cannot convert from foo to foo. Yes. The types are the
same. The iterator() call on the entrySet() return value returns a
java.util.Iterator<Map.Entry<T, Integer>>; the instance variable i is
explicitly declared as being of this same type.
Now what do I do?