From the course: Java 11+ Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Declare and initialize object variables - Java Tutorial
From the course: Java 11+ Essential Training
Declare and initialize object variables
- [Narrator] If a variable's data type isn't a primitive, then it's an object of some kind. When you build Java applications, you're creating classes. A class is essentially a template for creating objects. So for example, if I wanted to create a pattern where I could store information about types of clothing, I might create a class called clothing item. That clothing item class could have fields for data values and methods that knew how to do stuff. When you create an object variable, you're creating an instance of one of those classes. And because the classes can define fields for data values, and methods for actions, when you create the object that's an instance of the class, it has those fields and methods. In Java, a field is a variable that's a member of a class. A local variable is a variable that you declare inside of a method, while a field is a variable that's declared after the class declaration. Now we'll talk…
Contents
-
-
-
-
-
(Locked)
Work with primitive variables5m 43s
-
(Locked)
Declare and modify primitive values3m 27s
-
(Locked)
Declare and initialize object variables3m 40s
-
(Locked)
Manage currency values with BigDecimal3m 8s
-
(Locked)
Convert values between numeric types2m 40s
-
(Locked)
Math operators and the Math class2m 22s
-
(Locked)
Manage true and false Boolean values2m 43s
-
Manage character values as primitives3m 13s
-
(Locked)
More about Java operators5m 45s
-
(Locked)
-
-
-
-
-
-
-