The comments section of the DZone-syndicated version of my post "JDK 8 Versus JDK 10: Ternary/Unboxing Difference" had an interesting discussion regarding the "why" behind the "fix" for how Java handles autoboxing/unboxing in conjunction with the use of the ternary operator (AKA the "conditional operator"). This post expands on that discussion with a few more details.

One of the points made in the discussion is that the logic for how primitives and reference types are handled in a ternary operator; in particular, when autoboxing or unboxing is required, it can be less than intuitive. For compelling evidence of this, one only needs to look at the number of bugs written for perceived problems with Java’s conditional operator’s behavior where autoboxing and unboxing are involved:

Source de l’article sur DZONE

0 réponses

Laisser un commentaire

Participez-vous à la discussion?
N'hésitez pas à contribuer!

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée.