We have a possibility to make classes extend from other classes so they can inherent specific values
from other classes can help us to make our classes small simpler.
For example in our example we firstly delete like every song on out and we delete everything onto on
name there.
And then we make a second class call it's animal
and here we would basically say in page soul because and we can make also a class called that wired
life.
And then the.
Or something.
So you got different types of animals for example your pets and the animals which live in LAX wildlife
and these classes have the same attributes.
For example the age because every wildlife animal has an age and every pet has an age and they also
have like a weight height and maybe four or something.
So basically they've got things in common.
And we could just type them all out in all different classes.
For example you could start starting print on it.
So you like and age etc. and use it in this class.
But you had to also make it in this class.
We had to also type in h here if you want to use it also in our wildlife enema class.
But we can use what's called the superclass and to give it these attributes and then make our two classes
extend this superclass and then can access the values of our superclass.
And with this we don't have to type it all out twice and all our child classes.
So an example we just simply say age and you have like a string name for our pets last because pets
have a name.
And yes and if you want to extend to this animal classic we just simply type all extents and then the
name of our class will extend from and with what life animates and extends and then and Imler.
And now we can access this variable with our two other classes.
So if you want to make like
one to make like new new pet now we can simply say Wallasey equal it's pet like this.
We did our first example.
And then if you want to give it an H can simply say let the edge he quotes fall maybe.
And if we want to print it all you can just print art Alessi and then give it the H and if we run it
with C we get all four and we exist on H from a superclass element and set it to Phong right here and
then we read it out.
And this is like a simple example of an heritage and why we can why we use it.
At some points because it saves us time so we don't have to write it all that twice or more times if
we have different classes which want to extend from specific superclasses.