Boxing and Widening

前端 未结 7 1690
小蘑菇
小蘑菇 2020-12-30 08:22

What is the difference between these two. I know Boxing is converting primitive values to reference. What is widening. Also what should be the sequence first boxing should b

7条回答
  •  我在风中等你
    2020-12-30 09:18

    Widening is when assign byte to int. i.e. you are widening the data type.

    Sequence must be boxing then widening.

    You CANNOT widen then box (int cannot be Long).

    You CAN box then widen (int can become Object via Integer)

    Note: Highlighted words are from Sun Certified Java Programmer SCJP 6 - Kathy Sierra

提交回复
热议问题