String with a decimal point turn int java.lang.Double can not be cast to java.lang.Integer

 

String with a decimal point turn int

HashMap <String , Object> = the Map new new HashMap <String , Object> () ; 
map.put ( "taskID" , 10086 ) ;

the Map in a direct transition to take out of it will complain
(Integer) param.get("taskID")

java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer

解决方法
String taskId ="10086.0";
iTaskId = Double.valueOf(taskId).intValue();





 

 

Guess you like

Origin www.cnblogs.com/zhangcheng1/p/11982508.html