I am making bukkit plugin and one function returns List<Map<?, ?>>
, if I to do that:
List<Map<String, String>> circle = FileManager.area.getMapList("circles");
I get error that it can't be converted. What do to?
The error:
List<Map<?, ?>> cannot be converted into List<Map<String, String>>
You can cast away all the generics by casting to the raw type, (List)
:
List<Map<String, String>> circle = (List) FileManager.area.getMapList("circles");
Note that as with most casts this is unsafe - it's better to find a way to pass the correct type information through, as other answers suggest.
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