From the course: Java SE 17 Developer (1Z0-829) Cert Prep

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Wrapper classes

Wrapper classes

- Let's look at the wrapper classes. Package java.lang has wrappers for all eight primitive types. There's actually also a class Void with a capital V, but that doesn't actually wrap anything. It has no instances and the only thing you can assign to it is the null value. The names of the wrappers all start with a capital letter. Integer and Character become full words where the other wrappers use the primitives name simply with the first letter capitalized. The wrappers provide several things, a reference type that contains a primitive value and a home for primitive-related data and functions. So for example, there's integer.MAX_VALUE, MAX_VALUE with all the letters in uppercase, which describes the largest integer that can be represented. There's also functions like Double.toHexString that will convert a double value into a hexa decimal textual representation. When we're using the wrapper as an object that contains a primitive, the compiler will also automatically generate code to…

Contents