From the course: Java Essential Training: Syntax and Structure
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Wrapper classes - Java Tutorial
From the course: Java Essential Training: Syntax and Structure
Wrapper classes
- [Instructor] All primitive data types can also be expressed as objects via the use of wrapper classes. Here, we have two variables, number1 and number2. Number1 has a data type of int, which is primitive. And number2 has a data type of integer which is a wrapper class for the primitive data type int. This makes number2 an object. The benefit of using wrapper classes, as opposed to primitive data types, is the ability to utilize convenience methods that are available in the wrapper class. Wrapper classes exist for all primitive data types. Let's take a look inside of the integer wrapper class. The integer wrapper class is filled with helpful methods for working with integers. For example, there are fields for MIN_VALUE and MAX_VALUE which will return the minimum and maximum values for an integer memory space. There are the compare and compareto methods to compare integer values. There are methods that will allow you to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Defining classes for objects5m 22s
-
(Locked)
Constructors3m 7s
-
(Locked)
Instantiating objects4m
-
(Locked)
Objects as method parameters2m 9s
-
(Locked)
Objects as method return types1m 55s
-
(Locked)
Wrapper classes1m 54s
-
(Locked)
Records1m 51s
-
(Locked)
Code Solution: Create a car object1m 12s
-
(Locked)
-
-
-