Link to home
Start Free TrialLog in
Avatar of Jagdeep Singh
Jagdeep Singh

asked on

Type safety: Unchecked cast from Object to Map<String,String>

Getting "Type safety: Unchecked cast from Object to Map<String, String>" warning during the typecasting.

Could you guide me how I can resolve it?.  Please check below-mentioned code:-

Map<String, String> columns = ((Map<String, String>) map.get("columns"));
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Please post your declaration of 'map'

If it's all right then your code will work without warnings or casting (renamed to 'things' to avoid confusion)

Map<String, Map<String, String>> things = new HashMap<>();
Map<String, String> columns = things.get("columns");

Open in new window

Avatar of Jagdeep Singh
Jagdeep Singh

ASKER

Yes, it can help me.
-Thanks-
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.