From the course: Learning Java 11
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Review: Classes vs. instances - Java Tutorial
From the course: Learning Java 11
Review: Classes vs. instances
- [Narrator] So what are the big takeaways from this chapter? First, in Java, we can create classes to organize our code. In our previous example, we used a triangle class to organize data related to a triangle as well as how we can calculate things from triangle data. A class contains attributes and behavior, also called properties and methods. Every class also contains a constructor, which is a specific type of method that allows us to create instances of the class. Ultimately, a class is just a blueprint, and we have to use the constructor in order to create triangles in our code. Some of these attributes are associated with each individual instance, and we call these instance variables. These were the height, base, and side length attributes in our example. These attributes are accessed with the instance itself, and we use the dot operator on the instance to access instance variables. Along with instance variables,…
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)
Classes in Java4m 55s
-
(Locked)
Constructors in Java6m 50s
-
(Locked)
Creating a class in Java3m 57s
-
(Locked)
Creating instances in Java4m 57s
-
(Locked)
Instance methods vs. class methods2m 52s
-
(Locked)
Using instance methods in Java2m 47s
-
(Locked)
Instance and class variables in Java3m 56s
-
(Locked)
Review: Classes vs. instances1m 57s
-
(Locked)
Solution: Bank account balance1m 19s
-
(Locked)
-