Any way to cast java.lang.Double to java.lang.Integer?
java.lang.Double
java.lang.Integer
It throws an exception
"java.lang.ClassCastException: java.lang.Double incompatible with java.lang.Integer"
You need to explicitly get the int value using method intValue() like this:
Double d = 5.25; Integer i = d.intValue(); // i becomes 5
Or
double d = 5.25; int i = (int) d;
2.1m questions
2.1m answers
60 comments
57.0k users