Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java - Getting rid of a compiler warning?

i have the following line of code which displays the following warning:

HashMap<String,String> currentItem = (HashMap<String,String>) adapter.getItemAtPosition(position);
// Warning: Type Safety: Unckecked cast from Object to HashMap <String,String>

How can i get rid of this warning?

like image 768
aryaxt Avatar asked Jan 29 '26 17:01

aryaxt


1 Answers

Have the getItemAtPosition method return a generic HashMap, so you don't have to cast it. Either that or use the appropriate annotation -- @SuppressWarnings("unchecked")

like image 119
Hovercraft Full Of Eels Avatar answered Jan 31 '26 06:01

Hovercraft Full Of Eels



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!