Hi everyone in this theater real I'm going to touch about objects in Java.
OK.
So first of all we need to create a project so click on find new and then click on Java project.
OK.
And for the project name just type in here objects and click unfinished.
So as you can see here our project is now created.
So we need a class for our project.
So just click on this as our See folder or you can click on these objects project click on File New
and then click on a class.
OK.
So remember that for every project that you create in Java you'll need a main class.
OK so now we want to actually create a main class for our project.
Just type in here Main and for the package name just type in our reverse domain here come that your
name dot project name objects.
OK.
And for the modifiers choose public.
And here make sure that you check this check box here that says public static void main method.
OK.
This is going to be the starting point for actually running our Java code.
OK.
Otherwise our coats won't be executed at all.
OK so this method is very important but because this class that we are actually creating now is the
main class of our project.
This method is required for this class.
OK.
So just click on finish.
And as you can see here our class is now created and this is our main method.
Okay.
And here let me actually delete this comment here.
And in order to make this editor area a much wider DoubleClick undismayed that you have here.
So as you can see here are a little area is now much wider.
So as I said earlier in this tutorial I want to talk about objects.
OK so what are objects.
First of all let me point out that Java is an object oriented programming language.
OK so what is an object.
What do you see when you look at the world around you.
You see objects right in Java.
We've got the same objects too.
So so what is the definition of an object.
Objects are a representation of things.
Let's look at the world around us.
You see objects everywhere.
For example animals are objects.
OK.
A lion is an object a person is an object.
A pen is an object.
OK your desk is an object.
And lots of other examples.
So when you for example look at a lion you can write a tell me the characteristics and behaviors of
this lion.
OK.
For example the characteristics of a lion are a lion has powerful legs.
OK.
The second characteristic is a lion has a strong jaw.
The first characteristic is a lion is brave.
OK so now let's talk about the behaviors of a lion.
OK.
For example the behaviors of a lion are a lion spends much of his time resting and is in active for
about 20 hours per day.
OK.
That such behavior is an attempt to catch the victim with a fast rush.
The first behavior is a lawyer and takes advantage of the factors that reduce visibility OK.
So how we can relate this example to Java.
So first we need to create a Java class called the law.
OK.
So now let's actually create a Java class.
So click on this package here.
OK.
And then click on find new and then click on class.
So for the name of the class just type in here Lorient with the capital L..
OK.
And here for the package as you can see it's going to put this class inside this package.
OK.
So that's why I actually clicked on this package and then I started to create a class.
OK.
So this is really important.
So this class is going to be inside this package.
OK.
And for the modifiers to publish and then click Finish.
Our class is now created the name of our class is a lion.
OK so what is the class.
As I said earlier our class is a blueprint for creating objects.
OK.
Without a blueprint you cannot create an object.
So suppose that you want to create a car.
What would be the first step in order to actually create a car.
First of all you need a blueprint that shows you exactly how you can create a car.
OK.
So for example this is a blueprint for creating a car or create this blueprint is going to actually
show me exactly how I can create a car.
OK.
So in Java programming reach the blueprint is the class that we create in our projects.
OK.
For example this class is going to be our blueprint in order to show us exactly how I can create life
and objects.
OK.
So as you can see here there are no instructions inside this class.
So now I want to actually put some instructions inside this class in order to show me how I can create
loyal objects.
OK so now let's go back to our car example.
First of all you need a blueprint in order to show you exactly how you can create a car.
OK.
So a car has some characteristics and behaviors.
So what are the characteristics of a car.
OK.
The characteristics of a car are first of all a car has four wheels.
Second of all a car has the braking system and Firstly a car has a steering system OK and a car has
some behaviors too.
So what are the behaviors of a car.
Firstly a car can move.
And secondly a car can break.
OK so now let's go back to our code because I want to show you how you can create objects out of classes.
OK.
So now I want to give some characteristics to my life and class.
OK.
So first of all a lion can run very fast.
So now you want to actually create a variable in order to store the amount of speed that allow you and
can run OK.
OK.
The name of my variable is speed and that I can assign a value to my variable for example 100.
OK.
And then at the end of my statement I need to put in a semicolon.
So as you can see here this variable here is the characteristic of my line class.
Ok this argument here is going to show us what would be the amount of speed of our and objects.
OK so now I want to actually create an object from this class.
So how can I do that.
So first of all let me point out that always save your classes.
So if you are using too match or six just press on comment keep Plus the s key on your keyboard in order
to save your class.
But if you are using a Windows machine press on control key plus the key on your keyboard in order to
save your class.
OK.
So as you can see here there is a Lego Star here beside my class name.
OK.
So now if I actually save my project as you can see that little star is now gone.
OK.
This means that my class is now successfully saved.
OK.
So go back inside the main class and here you want to create an object from the slide in class.
Or you want to create a like an object.
OK.
So in order to create an object from a class.
First of all you're literally first to the name of that class.
So the name of my class is Lion as you can see here.
OK.
So so here I just need to type in line.
So as you can see here the name of my class is lion.
OK.
And here I want to give a name to my lion object.
So the name of my your object is my lion and then I want to instantiate my lion object.
OK.
I put an assignment operator here and then I'll use the new keyboard here.
OK this is very important.
Whenever that you want to create an object from a class you need to put this new keyboard after the
assignment operator OK.
This new key word means that we want to create a new object from that specific class.
In this case we want to create a new object from this class.
OK.
So new and again I need to refer to the name of my class line and then I put a pair of round brackets
after my class name.
And then at the end of my statement I need to put in a semi-colon.
OK.
So as you can see here our object is now created.
OK.
So now that our object is created.
So it's going to be saved inside the memory.
OK.
So in order to actually show you how this object is going to be saved inside the memory.
So first of all let me show you the address of this object inside the memory.
So I just need to type in here system that's out that print line and then inside the practices.
I just need to refer to the name of my object.
And then at the end of my statement I need to put in a semi-colon OK.
So now if you run my project as you can see this is the address of our object inside the memory.
Ok you don't need to know that where this object is actually saved.
You just need to know that your object is created and it is stored somewhere inside the memory OK.