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.

  1. If you use instanceOf You do not need to try-catch (classcastexception e) . exampleOf is guaranteed to work, even with null s

  2. In 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

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -