I don't understand why data.entrySet() and data.keySet() in the code below are giving me Type Mismatch in eclipse, though I specified the type in both cases in the for loop.
Is this normal or am I missing something that should I take into account when extending an abstract class?
import java.util.AbstractSet;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeMap;
abstract class SetDuplicates<K> extends AbstractSet {
public Map<K, Integer> data;
}
class TreeSetDuplicates<K> extends SetDuplicates {
public TreeSetDuplicates() {
data = new TreeMap<K, Integer>();
}
public Object first() {
for (Map.Entry<K, Integer> entry : data.entrySet()) {}
for (K element : data.keySet()) {}
}
@Override
public Iterator iterator() {
// TODO Auto-generated method stub
return null;
}
@Override
public int size() {
// TODO Auto-generated method stub
return 0;
}
}
