Widening and Boxing Java primitives

前端 未结 5 653
一生所求
一生所求 2020-12-07 01:33

Widening and Boxing Java primitives.

I know it is not possible to widen a wrapper class from one to another as they are not from the same inheritence tree. Why thou

5条回答
  •  被撕碎了的回忆
    2020-12-07 01:57

    If we allow too many magic conversions, it'll get very confusing.

    The existing conversion rules are already more than people care to understand. Even the language spec got it wrong! See this funny example Java casting: is the compiler wrong, or is the language spec wrong, or am I wrong?

提交回复
热议问题