From the course: Learning Java 11

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Review: Classes vs. instances

Review: Classes vs. instances - Java Tutorial

From the course: Learning Java 11

Start my 1-month free trial

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, each instance has instance functions or non-static methods…

Contents