Is there any way to check if the varible is Double or Long before doing anything with it? Sometimes the Objects are Double and some they are Long. How can I check it before using it?
if (obj instanceof Double) ...
You could use instanceof
.
public void someMethod(Object o)
{
if ( o instanceof Long )
{
// do stuff
}
else if ( o instanceof Double )
{
// do stuff
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With