An inline 20 I decided to output that value to the concert.
So this is that's what DO.
OK number 56.
So what's going on here.
So whenever we actually run our project it's going to actually execute this method here.
This main if it.
So inside of this method we are creating an object from this tiger class card.
My second tiger.
OK.
In Line 14 and it's going to actually execute our constructor OK are constructed inside the target class.
So.
So this is our constructor OK.
And then it's going to actually execute these lines of code inside of these constructor.
OK so this is how it's going to actually execute codes inside of our program.
OK.
So now I want to show you another important point about constructors in Java.
So first let me actually comment out these lines of code here.
OK.
And now I want to actually create multiple constructors for my higher class.
OK.
So as you can see here I created two constructors here and another constructor here.
OK so now I want to actually execute all of these constructors.
So I just need to delete these symbols here in order to allow the compiler to execute these lines of
code here.
OK so now I just need to delete these symbols here and here.
OK.
As you can see here.
Now I have actually three constructors.
So now it's showing us an error.
Let's actually hover over the error area and see what's the error.
Duplicate Somerford tiger type Tiger.
So as you can see here we have two constructors with the same name and with no arguments.
OK so this is not right.
We need to actually create a different constructor and this one in order to allow the compiler to execute
these lines of code here.
OK.
We cannot create duplicate constructivists with the same name and with the same argument type.
So here I want to specify that this constructor is going to accept an argument data type of my argument
is it and the name of my argument is not a.
OK.
And then I want to add this number here to the value of my argument.
OK so 56 plus number a.
OK.
And now as you can see we've got three different constructors inside the tiger class.
OK so this is our first constructor and this is our default constructor and this is our second constructor.
This constructor accepts two arguments so that we can actually pass two values to the constructor and
the first constructor is this constructor.
This constructor accepts one argument and then here in line 19 you are actually adding this number here
56 to the value of the argument here not a.
And then we are actually assigning the result of this operation here to our speed instance valuable
and in line 20 you are actually outputting that value to the console OK.
So inside the main class now as you can see here I want to actually run my project and see what happens.
So if I run my project now as you can see this is the value that is output to the console.
This is our default constructor OK.
So what's going on here as you can see here we didn't actually pass any values to the constructor here.
OK.
Now in line 14 inside the main class and inside the main Mefford we are actually creating an object
from this tiger class and the name of our object is my second tiger.
OK.
Of an approach AirTrans first is going to actually execute this main method.
Okay.
And then as you can see here in say the main If it is going to actually execute this line of code here.
Here we are actually trained to create an object from this tiger class.
So as you can see here it's going to actually execute the default constructor for our tiger class.
OK.
So inside the tile class this is our default constructor.
OK.
As you can see here.
This constructor accepts no argument.
So this is called the default constructor and then inside the constructor I decided to output some values
to the console and that value is this value here as a currency.
And now I want to actually pass two values to my constructor here.
So here I can actually put number three comma number 7 for example.
And as you can see here if I use on my project.
Now let's see what happens.
As you can see it's going to actually output this value to the console.
So this value is the result of execution of this constructor here.
OK.
When we actually create an object from the tile class it's going to execute the constructor that we
created inside the target class here.
OK this is our constructor and this constructor accepts two arguments with the data type.
OK so we passed two numbers as against the two integer numbers through this constructor number three
and number seven.
And then it's going to go inside the constructor and then it's going to actually execute these lines
of code here.
First we created a variable called result and then we tried to actually add the value of these two arguments
together and then be assigned that value to the result variable.
And that in line 14 we decided to output that value to the console.
Number three plus number seven is number 10.
Okay.
And now as you can see our first constructor accepts one argument as you can see here.
So let's actually pass only one value here.
And let's run our project again.
So as you can see here it's going to output this value to the console number 59.
So as you can see here I passed a number of free to this constructor and then it can actually execute
this constructor here.
OK this constructor accepts only one argument with the data type.
So I passed number three which is an integer number two this constructor here.
And then it's going to go inside of this constructor and that it's going to execute these lines of code
here in line 19.
We tried to actually add number 56 to the value of the number a argument.
So the value of the non argument is free as you can see here.
So 56 plus free is 59 and then it's going to assign that value to this instance variable and then it's
going to actually output that value to the concert.
So this value is the value of this instance of it.
And inside the main class if you want to actually access the value of this instance variable and output
that that's value to the console I'll just type in here system that out at Princeton and then inside
the prentices I can't just refer to the name of my object.
My second Tiger does get speed and then I need to put in a semi-colon at the end of my statement.
So now if I run on my project has again satisfied you again is output to the console OK.
This value is the value of the spit instance variable of DS.
My second Tigard object.
OK.
So now if I want to actually create another object from the tiger class here as you can see I just need
to refer to the name of my class tiger and the name of my object is my first object my first tiger.
OK.
And then I need to put in an assignment operator here and then I need to put in this new word and then
again I need to refer to the name of my class here.
So here I actually use the autocomplete feature of the eclipse by pressing on the control key plus the
space key on my keyboard.
As you can see it's going actually comment as these are free options.
The first one is the constructor.
Without no argument.
The second is a constructor with one argument and the first one is constructed with two arguments.
OK we can actually choose between these free arguments.
For example if I choose this one now I need to actually passing two values.
For example number three.
And number two.
And then I need to put in a semi-colon at the end of my statement.
And now if I on my project as you can see this value is out with the console number 5.
So number three plus number two is five.
OK.
As you can see here this constructor accepts two arguments.
And here we are actually adding the value of the first argument to the value of the second argument.
And we are actually out with that's why they go to the concert.
So this value is the result of execution of this constructor here.
OK.
I can't even actually pass one value to this constructor for example number two.
And if I run my project now as you can see it's going to output this value to the console.
So this value is the result of execution of this constructor here.
As you can see here number 56 plus number 2 is number 58 as you can see here.
OK.
And I can even actually pass no values to the constructor and if I get on my project as you can see
it's going out with this value to the console.
This is a default constructor.
OK.
So hopefully that makes sense and I think that's enough for constructor's in this tutorial and in the
other sections of this course.
I'll talk more about constructor's in terms of other important concepts of d'Artois.
OK.
So for now it's enough.
And if you have any questions about these constructivists please post the discussion in the course.
And thanks very much for watching and I'll see you in the next tutorial.