 Let's take a look at this program that calculates the area and perimeter of two rectangles. We start with the methods that do those calculations, and then in main, we declare variables for the width and height of the first rectangle, and print and calculate the area and perimeter. Then we set the width and height of the second rectangle, and calculate and print its area and perimeter. If there's nothing wrong with this program, it works exactly as advertised. But it's a bit clunky. We have the width and height as independent variables, and they're separate from the methods, get area and get perimeter, that work on them. Wouldn't it be nice if we could put them all in a box and tie it up with a nice neat bow? That is part of what objects do for us. They let us build a data structure where the related pieces of information, the width and height, are grouped together, and they allow us to group the methods that work on the width and height right alongside the data. We group things together in a class. Let's create a class called rectangle, which will go into a file called rectangle.java. In the class, we define the data that belongs to the class. A rectangle has a width and a rectangle has a height. These are called the class's properties, the things that a class has. You may also hear them referred to as attributes or fields. Think of this class as a blueprint that tells what a rectangle is made out of. In order to make an object from the blueprint, you have to construct the object. In the similar way that you have to construct a house out of a blueprint for the house. To construct objects from their blueprint, you need a constructor. Constructors are very special. They look like functions except they don't have a return type. Inside the constructor, you set the values for the properties. By default, a rectangle will have a width of 1.0 and a height of 1.0. You can also provide constructors with parameters. I can have a constructor where you tell me how wide and how high you want the rectangle to be, and I'll set the width to whatever you told me the width was, and the height to whatever you want the height to be. After I have the properties of the class and the constructors, I then put the methods, which are the methods that work on the data. I can have double get area, which returns the width property times the height property, and double get perimeter, which returns 2.0 times the width plus the height. We don't need any parameters for these methods. When they need to access width and height, they'll look at the properties, and they're right there because everything's all together in the object. Let's give it a try in the testrectangle.java file. Inside of main, we're going to construct a rectangle. It's like every other declaration we've done so far. We give the data type, in this case the class name rectangle, the variable name R1, and on the right hand side we initialize it by invoking the constructor with the new keyword. We want the new rectangle, and we'll use the default constructor. Rectangle is the class. R1 is the object. We also say that R1 is an instance of the rectangle class. Let's define another rectangle, R2, which will be a new rectangle with a width of 3 and a height of 5.5. Now let's call the methods. Instead of doing it the way we had to do it before, by saying R1.width and R1.height, namely the non-object way, instead we'll use the dot notation just as we used with strings to call the methods. We'll set area1 to be R1.getarea. You might want to read this from right to left. Invoke the get area method using the data belonging to R1. And we'll have perimeter1 be R1.getparimeter. We're telling R1 to invoke its getparimeter method, or again from right to left, invoke the getparimeter method using the data that you find in R1. And let's print out the results. Let's save that and compile it, and let's run it. And let's do likewise for the second rectangle, which we'll do without intermediate variables. We'll print area and perimeter, and this time we'll tell R2 to use its getarea method, and we'll call the getparimeter method for the object R2 to use its data. Let's compile and run, and that works as well. And that's a quick overview of objects. In the next videos, we'll go into more detail about classes, properties, constructors, and methods.