How to declare a headset using double as datatype?
public HashSet priceSet() {
Set<double> hSet = new HashSet<double>(); //<==== netbeans warn this line
for (Map.Entry<String, Tablet> entry : tableMap.entrySet()) {
hSet.add(entry.getValue());
}
return (HashSet) hSet;
}
what’s the problems of this line?
Set hSet = new HashSet();
Set is used for storing objects, not primitives. So you should use wrappers to use it with primitives – like
edit
provided you have some
doublevariable, you add it likehowever
entry.getValue()isTablet, so it seems you need to use something likeedit2 actually
(Double)isn’t necessary