Hire everyone in this theater all I'm going to go ahead and talk about using methods and objects together.
OK.
So first we need to create a Java project.
So in order to create a Java project we need to click on this file new and then click on Java project.
OK.
So for the project name just type in here objects and methods.
So as you can see here our project is now created.
So first we need our class for our project.
So just click on this as RC for that.
Or you can click on these objects and methods project and then click on file name and click on class.
So here for the class name just type in here Main and for the package name we need a reverse domain
here.
So I typed in here com that's my name and find out the project is public.
And here make sure that you check this checkbox that says public static void main if it OK and then
click on finish.
So as you can see here our class is now created.
So first let me actually delete this comment here.
And then in order to make this a little earlier Vider I just need to double click undismayed that job
I have here.
So as you can see here our editor area is now much wider.
And then we can actually write our coats in this method.
OK.
In this main method.
So this main effect is the starting point for actually running.
Our job coats.
Okay.
So first of all I want to create an object.
Okay.
So in order to create an object you need to have a blueprint in order to show me exactly how to create
an object.
OK.
So in Java in order to have a blueprint for showing us how to create an object we need to create a class.
OK.
So our class is like a blueprint in Java.
OK.
So let's first create a class called liar.
OK.
So in order to create a class of we just need to click on this package here.
OK.
And then we need to click on File knew and then click on class.
So for the class name just type in here line.
And as you can see here it's going to actually put our class inside this package.
OK.
So that's why we actually clicked on this package.
And then we started to create a class.
OK.
So for the modifiers the public.
And then click on finish.
So as you can see here our class is now created.
OK now we need to actually put some instructions inside this class in order to actually show us how
to create life and objects.
OK.
So as you can see here now that our client class is created we have our blueprint.
OK.
But there are no instructions in this blueprint in order to show us exactly what are the characteristics
and behaviors of a lawyer.
OK so now we can put some instructions inside this blueprint.
So first I want to put the characteristics of a lion inside this class.
OK.
So the characteristics of a lion are for example and speed.
And then I can assign a value to this variable for example number 90.
OK.
Int power for example 100.
OK.
So these are the characteristics of a liar.
OK.
Now you want to specify the behaviors of a lion.
So for example the behaviors of a lion are for example a lion roll.
OK.
So in order to show their behaviors of an object we need to create Misfit's.
So in order to show how my lawyer rolls we need to create a method.
So I just let you type in here void and the name of my method is wrong.
OK.
And then I need to put in a pair of round brackets after my Meffert name.
And then I need to open and close my Meffert by using an opening curly brace followed by our closing
calibrates.
OK.
And then inside is left.
I can put in my statements.
So now you want to show how my lane roads.
So I just made you type in here system that's out that pretty learn and an inside Apprentice's I put
in two double quotes and the inside double quotes.
I just tried roll
and then at the end of my statement I need to put in a semi-colon.
So this is how my lawyer was OK or for example El-Aurian runs OK.
So I just need to type in here Voyt run and then I need to put in a pair of round brackets after my
name.
And then I need to open and close my fit by using an opening curly brace followed by our closing curly
brace and then inside I'm afraid I can put my statements.
So I just type in here system
out that Princeton and then inside the apprentice's I can just put into double quotes and here I write
run.
So this is how my lion runs.
OK.
Or for example my lion fights.
OK.
So I just let you type in here.
Voyt fight.
And then I need to put in a pair of round brackets and then I need to open and close my left and then
inside the Smurfette I can just put in my statements.
So I just type in your system that out that Priestland and that inside the prentices I put into double
coats and that inside the double quotes I right fight
thought this is how my lion fights OK or for example my lion sleeps.
So again I can just I've been here voit.
So as you can see here the return type of mine if it is void my method is going to return nothing.
OK.
It's just going to actually do something.
OK.
And the name of my method is sleep and then I need to put in a pair of round brackets after them if
at any.
And then I need to open and close my Minford by using these curly braces as you can see here.
And that inside this method I can put in my statements.
So I just type in here system that out that princeling.
And then inside the prentices I can't just put into double coats and then inside the double quotes.
I just right sleep so this is how my lion sleeps.
OK.
So now that's my blueprint is ready we can actually create loyal objects from this class.
OK.
So inside the main class and then inside the main Mfat I can create an object.
So first of all I need to refer to the name of my class line.
OK.
And the name of my object is my lawyer.
And that I need to between an assignment operator here and then I put in this key vote new.
OK.
And then again I need to refer to the name of my class and then I need to put in a pair of round brackets
after my class.
OK.
And then I need to put a semi-colon at the end of my statements.
So as you can see here first of all I referred to the name of my class line and I gave my object a name.
OK.
And then I put an assignment operator here.
And then I put this key vote here knew.
OK so here we are actually telling the computer that if you are going to actually create a new object
from this loincloths.
OK.
So that's the job of this new Q-Bot here.
And then you are actually telling Dad we are going to create a new object from this class.
OK.
So first of all you are actually referring to the name of our class and then we are actually giving
our object a name and then we use this assignment operator and then we're actually instantiating our
object.
OK.
You are actually creating a new object from this class.
So as you can see here our object is now created inside a memory.
So now in order to show you how my object is created and what is the address of my object inside the
memory.
I just need to type in here system that out that learn and then inside the apprentice's I can just refer
to the name of my object my lawyer.
And then at the end of my statement I need to put in a semicolon.
So now if I run on my project as you can see this is the address of my lawyer an object inside the memory.
Ok this is just a way to show you that our object is actually created inside a memory.
OK.
And this is the address of this my client object inside the memory OK.