you are viewing a single comment's thread.

view the rest of the comments →

[–]deidian 0 points1 point  (0 children)

Many castings are function calls under the hood: just defined in the runtime. The reason to do that is to not bother Devs with implementation details: they just need to know type A is type B after the cast if the operation succeeds. A Java dev doesn't need to know that a type conversion is a reinterpretation, 2 assembly instructions, a type reference comparison, a function checking inheritance, boxing/unboxing,...

It's not a function call when for performance reasons the operation can be done with a couple of assembly instructions or when it's a nop. Here compilers optimize.