//**************************************** public class Main { public static void main(String[] args) {
// polymorphism = greek word for poly-"many", morph-"form" // The ability of an object to identify as more than one type
Car car = new Car(); Bicycle bicycle = new Bicycle(); Boat boat = new Boat();
Vehicle[] racers = {car,bicycle,boat};
for(Vehicle x : racers) { x.go(); }
} } //**************************************** public class Vehicle { public void go() { // TODO Auto-generated method stub
} } //**************************************** public class Car extends Vehicle{ @Override public void go() { System.out.println("*The car begins moving*"); } } //**************************************** public class Bicycle extends Vehicle{ @Override public void go() { System.out.println("*The bicycle begins moving*"); } } //**************************************** public class Boat extends Vehicle{ @Override public void go() { System.out.println("*The boat begins moving*"); } } //****************************************
I know im asking randomly but does any of you know a way to get back into an Instagram account?? I somehow forgot the login password. I appreciate any tips you can give me
@Billy Dominic i really appreciate your reply. I found the site thru google and Im in the hacking process atm. Looks like it's gonna take quite some time so I will reply here later when my account password hopefully is recovered.
I had struggled with figuring out what polymorphism is for weeks But with just watching this video I feel the power in my hands, everything is so clear now I extremely respect what you did
another way is to use instanceof inside the for loop, we each time check : if ( x instanceof Car ) x.go(); if ( x instanceof Bicycle ) x.go(); if ( x instanceof Boat ) x.go(); In case someone don't want to redefine the method go in superclass
Loop Through an Array with For-Each There is also a "for-each" loop, which is used exclusively to loop through elements in arrays: for (type variable : arrayname) { ... } example:- String[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; for (String i : cars) { System.out.println(i); } output:- Volvo BMW Ford Mazda
Thanks, nice video. In this case the parent class can be modified and x method was included. What if we need to extend somebody's else class? Implement an Interface?
It’s a for-each loop. It’s a variant of the for loop (kind of like the do loop is a variant of the while loop.) This same youtube goes over the concept in one of the videos in his 100 Java playlist. It’s probably the best (yet most underrated) explanation out there. Here’s a link: ua-cam.com/video/_IT8F5W0ZO4/v-deo.html
//****************************************
public class Main {
public static void main(String[] args) {
// polymorphism = greek word for poly-"many", morph-"form"
// The ability of an object to identify as more than one type
Car car = new Car();
Bicycle bicycle = new Bicycle();
Boat boat = new Boat();
Vehicle[] racers = {car,bicycle,boat};
for(Vehicle x : racers) {
x.go();
}
}
}
//****************************************
public class Vehicle {
public void go() {
// TODO Auto-generated method stub
}
}
//****************************************
public class Car extends Vehicle{
@Override
public void go() {
System.out.println("*The car begins moving*");
}
}
//****************************************
public class Bicycle extends Vehicle{
@Override
public void go() {
System.out.println("*The bicycle begins moving*");
}
}
//****************************************
public class Boat extends Vehicle{
@Override
public void go() {
System.out.println("*The boat begins moving*");
}
}
//****************************************
I know im asking randomly but does any of you know a way to get back into an Instagram account??
I somehow forgot the login password. I appreciate any tips you can give me
@Kalel Darian Instablaster =)
@Billy Dominic i really appreciate your reply. I found the site thru google and Im in the hacking process atm.
Looks like it's gonna take quite some time so I will reply here later when my account password hopefully is recovered.
@Billy Dominic it worked and I now got access to my account again. Im so happy:D
Thanks so much you saved my account :D
@Kalel Darian Happy to help :D
I had struggled with figuring out what polymorphism is for weeks
But with just watching this video
I feel the power in my hands, everything is so clear now
I extremely respect what you did
same :v ổng giảng cuốn thật
@@anleuc3246 tưởng có mỗi tôi là người Việt subscribed kênh này :v
ui cong dong nguoi viet day roi, chao cac ban, chuc cac ban hoc vui va thanh cong trogn su nghiep
Better than my teachers ❤️
thanks Abhishek!
Ofcourse
Not even comparable to mines😂
@@bestechdeals4539 same here
😂
another way is to use instanceof inside the for loop, we each time check :
if ( x instanceof Car ) x.go();
if ( x instanceof Bicycle ) x.go();
if ( x instanceof Boat ) x.go();
In case someone don't want to redefine the method go in superclass
we call it narrowing down in polymorphism
great video bro! Also in your examples can you include user input, i think its an important skill to memorize
great video!!! I'm infinitely grateful for your dedication and big heart to share this knowledge with the world. Thank you soo much
As always: a brilliant and helpful tutorial vid! I really appreciate you content, it really helps me learn Java!
Keep up the good work bro!
This is the best video to understand polymorphism. No doubt! Thank you a lot Bro ❤
You are the best Bro. I really appreciate what you did. May the God bless you and keep you enjoy with a happy and relax life all the time.
good mr bro
I didn't know u could tell a for loop to go through all entries of an array. That's super useful
Loop Through an Array with For-Each
There is also a "for-each" loop, which is used exclusively to loop through elements in arrays:
for (type variable : arrayname) {
...
}
example:-
String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
for (String i : cars) {
System.out.println(i);
}
output:-
Volvo
BMW
Ford
Mazda
@@mohammeds6314 thanks
@@hytalefanboi7471 most welcome:)
Awesome explanation as always!
Better than God Viedeo
Easy as f**k, thank u Bro.
Well this was more effective than my W3Schools, school lesson, and ChatGPT combination learning method. Thanks Bro Code!
Nice!
nice work bro
very good teachin and clear example. Thank you!
amazing
This was a good video
smashed the like button;
dropped comment;
subscribed;
so now I'm fellow bro, bro;
Wow!
Thanks, nice video. In this case the parent class can be modified and x method was included. What if we need to extend somebody's else class? Implement an Interface?
Nice.
Thanks for this videos, you are the best lecturer bro!
This is my 2# step. Great video bro
Bro, you are the best!
Goat of all bro
Thanks a lot bro
Nice bro
Good bro
all love your amazing mate
Thanks 🎉
Gods bless you.
Thanks bro
Thanks Bro
Nice
totally amazing tutorial, you got my subscribe after the second video. Thank you so much sir!
thanks man. keep up
You are a god of gods
This is kinda similar to array of objects like within a single object we are storing the other objects as well.
your vids are great
Good job, man!
Good
This helped a lot, thanks!!
I was talked to and learned something new (y)
Thanks
thanks for your best explanation
Thank you very much!!!
Powerful,very educ
ative and easy to understand,thanks bro code
Great example
Thanks, Bro!
very helpful, thanks
Thank you!
You are so brosome :)
this was helpful, thx
Your explanations are perfect
Great video
great video !!!
now I'm a hero thanks to you Bro
Appreciate it man!
tx bro
Great stuff!! 💪
Very clear video
👍
Thanks for the lesson!
Thank you for everything my bro :D you have helped me so much with your videos :DD!!!!
As simple as that . THANKS Bro
Awesome
youre the best ❤
I like it!
best brooo
this is the best java oop course
Good job!
very good for me! thank you
thx bro!
Thank you so much sir.
This was helpful, thank you!
Thank You So Much
0:29
What's the difference between abstract and interference
sagol
thank you !
How to using polymorphisme in java GUI ?
thanks babes
Thankss :)
4:50
comment
Just a comment down below
You should teach college classes!
I just don't understand how you can call other classes from the Main. You're not even including the package. Please help me understand this magic!
Just use "IntelliJ" (simpler) or "Android Studio" (more complex) and things become clear.
Does any one knows how to save the polymorphism code in java?
What do you mean by "save the polymorphism code" ?
I didn't understand that for loop😭
It’s a for-each loop. It’s a variant of the for loop (kind of like the do loop is a variant of the while loop.) This same youtube goes over the concept in one of the videos in his 100 Java playlist. It’s probably the best (yet most underrated) explanation out there. Here’s a link:
ua-cam.com/video/_IT8F5W0ZO4/v-deo.html
bro
plz
bahabikkkkkkkkkkkkkkk
The ammount of times this man has saved me this semester is unreal.
Thanks