Overriding e overloading – Java in 2 minuti #20

Overriding e overloading – Java in 2 minuti #20


By Chiccodb00
https://www.youtube.com/channel/UCtF8xxYtL6cVSVP2wkMj1Sg Hi, I’m Chiccodb00 in this episode of Java in due minutes,
I will explain the overriding and overloading. These two terms are
used respectively, to replace a parent class method
with one of the daughter class then it changes the behavior of the method conversely, overloading
is used to create and implement methods
with the same name but with different parameters. Now the examples, always
in the PallaTennis class we might have an overriding
in the cambiaTipo method, as we want him to
ignore the parameter and that the type is always “tennis”,
we will implement it this way: public void cambiaTipo (String tipo)
this.tipo=“tennis”; However, we could still
do a class overload for example by implementing a
method with the same name, only that it will be without
parameters, so we will write: public void cambiaTipo ()
this.tipo=“tennis”; So, by summing up, the difference
between the two methods I just wrote is that in the first, it
changes its “behavior” as it no longer sets the
type to the parameter but always in “tennis”, while in the
second we are doing a overloading as while the name remains the same, and the function is the same, it
will not have any parameters. If the video helped you
understand the subject, leave a like! otherwise leave a dislike Anyway, you can always comment on it
to help me improve future videos.

Leave a Reply

Your email address will not be published. Required fields are marked *