What are wrapper classes in Java?

A?wrapper class?in Java converts a primitive data type into class object.

Java is an object-oriented language that only supports pass by value. Therefore, wrapper class objects allow us to change the original passed value. These wrapper classes help with multithreading and synchronization because, in Java, multithreading only works with objects. Moreover, most collections (like?Vector,?LinkedList, etc.) work with objects.

No alt text provided for this image


No alt text provided for this image

Autoboxing

The automatic conversion of primitive data types into its wrapper class objects is known as?autoboxing.

No alt text provided for this image

Unboxing

The automatic conversion of wrapper class objects into its primitive data types is known as?unboxing.

No alt text provided for this image


要查看或添加评论,请登录

社区洞察

其他会员也浏览了