Back
How can I cast an Object to an int in java?
Assuming the object is an Integer object, then you can do this:
int i = ((Integer) obj).intValue();
If the object isn't an Integer object, then you have to detect the type and convert it based on its type.
31k questions
32.8k answers
501 comments
693 users