//**************************************** 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
my classmates and my batchmates kept on asking me how come i already know all the topics our professor taught.. i told them i binged watch youtube tutorial on your channel and ask them favor subscribe , like and comment . so you'll make more videos for us... we learned so much from you more than what is taught in our school we so much appreciate your efforts bro..🥰🥰🥰
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?
//****************************************
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
The ammount of times this man has saved me this semester is unreal.
Better than my teachers ❤️
thanks Abhishek!
Ofcourse
Not even comparable to mines😂
@@bestechdeals4539 same here
😂
Wow, astonished on how well explained that was. Great video.
my classmates and my batchmates kept on asking me how come i already know all the topics our professor taught.. i told them i binged watch youtube tutorial on your channel and ask them favor subscribe , like and comment . so you'll make more videos for us... we learned so much from you more than what is taught in our school we so much appreciate your efforts bro..🥰🥰🥰
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
This is the best video to understand polymorphism. No doubt! Thank you a lot Bro ❤
great video bro! Also in your examples can you include user input, i think its an important skill to memorize
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!
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.
Very good video thank you from Kazakhstan
great video!!! I'm infinitely grateful for your dedication and big heart to share this knowledge with the world. Thank you soo much
very good teachin and clear example. Thank you!
You are the best, thank you for helping me through college
This is my 2# step. Great video 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:)
Great video simple and clear
Well this was more effective than my W3Schools, school lesson, and ChatGPT combination learning method. Thanks Bro Code!
Thanks for this videos, you are the best lecturer bro!
thank you so much, i watched many vids trying to learn this stuff, no one can teach it like you do
Thank you for making these videos. Great content.
Thanks great job keep going
nicely explained, thanks good for repeating :))
That was incredible good explained. Thanks!
Powerful,very educ
ative and easy to understand,thanks bro code
thanks for your best explanation
This helped a lot, thanks!!
Awesome explanation as always!
Nice bro. Right to the point. Gracias.
totally amazing tutorial, you got my subscribe after the second video. Thank you so much sir!
concise and precise.Thanks
smashed the like button;
dropped comment;
subscribed;
so now I'm fellow bro, bro;
As simple as that . THANKS Bro
Easy as f**k, thank u Bro.
very helpful, thanks
Your explanations are perfect
I was talked to and learned something new (y)
Thanks for your video
now I'm a hero thanks to you Bro
Bro, you are the best!
You are the GOAT!!!
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?
Great example
Thanks for the lesson!
this is what ive been looking for thanks bri co
your vids are great
great job!!!
Nice bro keep going you are well🙏
great video !!!
Brilliant tutorial!
Thank you for everything my bro :D you have helped me so much with your videos :DD!!!!
Wow!
Goat of all bro
good mr bro
very good for me! thank you
Nice!
This was helpful, thank you!
Thank you very much!!!
Thanks a lot bro
This is kinda similar to array of objects like within a single object we are storing the other objects as well.
Great stuff!! 💪
Gods bless you.
youre the best ❤
Thanks 🎉
It works even if vehicle is an abstract class?
all love your amazing mate
Thank you so much sir.
Awesome
This was a good video
👍
You are a god of gods
Nice.
amazing
Very clear video
Best explanation
I like it!
best brooo
thanks man. keep up
Thanks bro
Thanks🎉
Thank You So Much
Thanks, Bro! ☕ You're awesome!
Thanks Bro
Good job!
Great video
Better than God Viedeo
this was helpful, thx
super clear thanks
Thanks
Thank you!
You are so brosome :)
Thanks, Bro!
Appreciate it man!
Thanks so much Bro!!!
Good job, man!
what if one of the 'objects' of the parent class didnt have the go( ) method?
Thanks bro :)
nice work bro
this is the best java oop course