Map value类型不同的写法


Map value类型不同的写法
Map<String, Object> accountMap=new HashMap<String, Object>();
int userId = data.get("userId").getAsInt();
int accType = data.get("accType").getAsInt();

String name =  data.get("accType").getAsString();

accountMap.put("userId",userId);
accountMap.put("accType",accType);

accountMap.put("name ",name );




Integer userId= (Integer) accountMap.get("userId");
String name = (String) accountMap.get("name");
要么强制转换,要么value只能存一种类型

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM