object - Does using instanceof help and java cast type exception hits performance? -
I use legacy libraries and need to use the cut object in the archive. To avoid the exception, I'm thinking of using the example. So ask questions: 1. If I use the example - try the trick. Hold exception to avoiding exceptions. 2. Does it perform performance? Thank you.
-
If you use
instanceOf You do not need totry-catch (classcastexception e) .exampleOf is guaranteed to work, even withnull sIn today's VM, casting Do not show any criteria performance. Rather, if you start casting many more times, then revisit your design.
Note:
For example, does not work with generics due to errors.
Comments
Post a Comment