I was wondering how computationally expensive is using instanceof operator in java and wanted to know if there are any better alternatives available
I was wondering how computationally expensive is using instanceof operator in java and wanted
Share
The alternative is to avoid using
instanceofand design your classes properly (in OO sense).As the
instanceofoperator has a corresponding “instanceof” byte code instruction, there probably won’t be a more performant approach; but this may also depend on how the actual JVM optimizes.