This type of constructor is called the default constructor OK.
In this example we are creating the no argument constructor in the Tiger class.
It will be invoked at the time of object creation.
OK so as you can see here inside the main class we are creating an object for this type of class.
So now me actually comment out these lines of code here because I want to create another and other object
from your class.
So first I need to refer to the name of my class and the name of my object is my second tiger.
And then I put an assignment operator here and then I put this key word here new and then I referred
to the name of my class name again Tiger and then I put a pair of down brackets after my classily.
OK so now as you can see I created an object from this tiger class.
OK.
So now the inside of this tiger class I want to actually output some values to the console when ever
an object from the tiger class is created inside of this tiger constructor I just need to type in system
that out that print land and then inside the apprentice's I just need to put in two double quotes and
then inside it all coats I just need to typing this.
Default
constructor OK.
So as you can see here I created a constructor inside of my tiger class and inside of this constructor
I decided to Outwood some values to the console.
So inside the main class as you can see we created an object from this tiger class and the name of this
object is my second tiger.
OK.
So now if I it on my project let's see what happens.
So as you can see here this is the value that is outputted to the console.
And this is our default constructor.
OK.
So inside of this main class and inside of this main method we didn't try to actually output anything
to the console and we only actually created an object from this tile class in line 14 inside of the
main method.
OK.
But inside of the target class we created our default constructor with no arguments and inside of this
constructor I decided to output some values to the console.
OK so this is that value.
OK.
And remember that we can actually create unlimited constructors in our classes.
OK.
So for example this is called the default constructor and I can actually create a padded motorized constructor
OK constructor with argument list is known as padding meteoroids the constructor.
So anality actually comments out of this constructor here and now I want to actually create a parametrized
constructor.
OK so here I just need to type in public OK the access modifier of my constructor is public and the
name of my constructor must be the same as the name of the class Tiger and I need to put on a pair of
round brackets after my constructor name and that I need to open and close my constructor by using these
curly braces.
So as you can see here I want to actually specify that this constructor is going to accept some values.
OK we can actually pass values to the constructor.
So inside of this prentices I can just typing int for example Nahm one.
And then I can actually create another argument ain't none too ok.
I can actually create a variable for example int result and then I can put in an assignment operator
here refers to the name of my non-valid argument plus numb to argument.
OK.
And then I can output the value of the result variable to the console.
So I just need to type in her system thought out that princeling and an inside the practices.
I can't just refer to the name of the results variable and then I need to put in a semi-colon at the
end of my statement.
So now inside of the main class as you can see it's now showing us an error.
OK so let's actually hover our mouse pointer over the error area and see what's the error.
So as you can see here it says de-construct here Tiger is undefined.
OK.
So as you can see here we created a constructor inside of the tiger class that actually accepts arguments.
OK.
So the default constructor is not going to be called anymore.
So we need to actually call this constructor from now on.
OK.
So inside of the main class if I actually delete this tiger class name here and if I just refer to the
name of my pager class and if I actually use the autocomplete feature of the eclipse by pressing under
control key plus the space key on my keyboard as you can see it's now recommending us to choose this
option here Tiger and in say the prentices is not one comma in into number two.
So if I choose this option as you can see I can actually pass some values here.
The first value that you want to pass is number two.
And the second value that you want to pass is number four.
And I need to put in a semi-colon at the end of my statement.
So now if I get on my project let's see what happens.
As you can see this value is now outputted to the console.
So as you can see here in line 14 I created an object from the tiger class.
OK.
So then my project runs.
It's going to first actually run the codes inside of this main if.
OK.
And inside of this main effect I created an object from this tiger class in line 14.
OK.
And as you know a constructor is a block of code which is going to be run whenever you actually create
an object.
OK.
So then you actually create an object from the target class it's going to actually add on our constructor.
OK.
Inside the Target Class.
So as you can see here this is our constructor for our tiger class.
OK.
And then it's going I cheated on the codes inside of the constructor.
So as you can see here I created a value here called result and then I decided to actually assign the
result of this operation here to this variable and an inline 14.
I decided to Outwood that value to the console.
So this is that value OK number 6.
So number two plus number four is number six.
OK.
So now if I actually comment out this constructor here as you can see let's see what happens inside
the main class.
It's now showing us an error.
So now let's actually hover our mouse pointer over error area and see what's the error.
OK.
As you can see here the constructor's Tiger Prentice's it.
It is undefined.
OK.
What's the problem inside the tiger class.
We don't have any constructor which specifies that it's going to accept two arguments of type integer.
OK.
As you can see here we commented out this constructor here.
So it is not going to be executed anymore.
So we need to actually use the default constructor which has no arguments.
As you can see here now the error is gone.
And if I had on my project again nothing is going to happen here.
OK.
As you can see inside the console Nothing is here.
OK.
Why.
Because you are actually creating an object from the target class as you can see here.
We didn't create any constructor inside of the target class.
So it's going to actually execute the default constructor OK.
And now I want to actually show you and other important point about constructors.
So inside the tigers of a fight as you can see here let's say that let's say that I don't want to actually
assign any values to this instance value but ok.
16 inside the target class I just declare it an instance variable called speed.
I'm not assigning any values to this instance value but OK.
So after creating this instance variable.
Now I want to create another constructor for Tiger class.
OK.
So again the access modifier of this constructor is public.
And the name of the constructor must be the same as the name of the class tiger.
OK.
And I need to put in a pair of and brackets after my constructor name and then I need to open and close
my constructor by using these curly braces.
So now I can actually refer to the name of my spit instance variable and then I can assign a value to
this instance variable.
Ok so now if you want to output that value to the concert I just need to type in system that out that
insulin.
And then inside the prentices I can just refer to the name of my speed instance variable and then I
need to put in a semi-colon at the end of my statement.
So now inside the main class as you can see here I created an object from the tiger class.
OK.
So now if I need on my project let's see what happens.
As you can see this value is now outputted to the console.
This value is the value of this speed instance variable that we created inside the tiger class.
OK.
But we created another constructor here inside the tiger class I assigned a value to this speed instance
variable.
So as you can see here in line 16 I just declared this instance valuable.
But inside of this constructor I decided to actually assign a value to this spit instance variable in
line 19.
OK.
As you can see here.