What is Autoboxing and Unboxing in Java? - 045

Опубликовано: 28 Март 2016
на канале: Deege
36,615
983

Let's start with the number classes, and then we'll talk about how Java uses autoboxing and unboxing to convert these classes to and from Java primitives.

In earlier videos we looked at the primitive data types for numbers. They were the bytes, shorts, ints, longs, floats, and doubles.

The java.lang package also includes a wrapper class for each of these primitive data types. All of the number types are subclasses of the Number class.

Java converts between numbers and primitives automatically using something called autoboxing and unboxing.

Autoboxing is when Java automatically converts a number primitive to an instance of the corresponding number class. The simplest example of this is when you declare a number class instance.

Unboxing happens in the other direction. This is when we have the number class, but Java is expecting the primitive. In this case, Java "unboxes" the primitive from the wrapper class.

#java #programming #tutorial


Like the video? Don't forget to subscribe! ➜ http://www.deegeu.com/subscribe


Keep up to date with the newsletter! ➜ http://www.deegeu.com/newsletter/

Concepts: Java autoboxing and unboxing, Java Number classes, Java converting types

Social Links: Don't hesitate to contact me if you have any further questions.
WEBSITE : [email protected]
TWITTER :   / deege  
FACEBOOK:   / deegeu.programming.tutorials  
GOOGLE+ : http://google.com/+Deegeu-programming...

About Me: http://www.deegeu.com/about-programmi...

Related Videos:
   • What important Java Terms do I need t...  

Media credits: All images are owned by DJ Spiess unless listed below

Music
Smooth Sailing (with Guitar) by Audionautix is licensed under a Creative Commons Attribution license (https://creativecommons.org/licenses/...)
Artist: http://audionautix.com/