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 be done or widening should be done?
Widening is transforming a variable in another with a wider type.
Widening can be done with primitive or reference types.
For example :
String
-> Object
int
-> long
As the JLS states :
a boxing conversion (§5.1.7) [is] optionally followed by a widening reference conversion
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With