I have an "unchecked cast from Object to Map.Entry" on "Map.Entry entry = (Entry) o;"
I think everything is OK and I can put an add suppress warning safely but I'm not sure. Here's my code.
public abstract class WebPath {
protected Hashtable<String, String> wp;
public String get(String whatDoYouWant) {
for (Object o : wp.entrySet()) {
Map.Entry<String, String> entry = (Entry<String, String>) o;
if (whatDoYouWant.equals(entry.getKey())) {
return (String) entry.getValue();
}
}
return null;
}
}
Thank you everybody, have a good day !
Don't suppress the warning, it's giving you good advice! You are choosing to assign each entry to the uninformative base class Object, instead of the more precise type, Map.Entry<String, String>. If you fix your for-loop you will eliminate the warning:
for(Map.Entry<String, String> o : wp.entrySet()) {
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With