Casting an Object (Upcasting and Downcasting) - Java Tutorial

  Рет қаралды 65,902

Bill Barnum

Bill Barnum

Күн бұрын

Пікірлер: 117
@BillBarnum
@BillBarnum 5 жыл бұрын
📌 Subscribe For The Latest Videos: bit.ly/36H70sy 📌 . 💻 All Java Tutorials: bit.ly/JavaTutorialsKZbin 💻 . 🤖 Learn Java In 3 Hours: bit.ly/JavaIn3Hours 🤖
@jbayg
@jbayg 3 ай бұрын
OH MY GOODNESS THIS IS THE CLEAREST EXPLANATION OF UPCASTING THANK YOU
@chandan07talreja
@chandan07talreja 6 жыл бұрын
Awesome man. A visual representation always helps in better understanding. Keep posting more videos.
@raxkhmanLite
@raxkhmanLite 4 жыл бұрын
Indeed, this video is one of the best explanation on casting of objects out there!!!
@BillBarnum
@BillBarnum 4 жыл бұрын
Thanks for the feedback. I'm glad you liked the video!
@bennails3447
@bennails3447 3 жыл бұрын
Legendary video on the subject. The best've I found on KZbin so far!
@BillBarnum
@BillBarnum 3 жыл бұрын
Wow, thanks!
@sp_aryan6
@sp_aryan6 2 жыл бұрын
from India, watching it the night before exam. thanks a lot for making a short easy to understand video.
@BillBarnum
@BillBarnum 2 жыл бұрын
Good luck on your exam!
@unityorder
@unityorder 4 жыл бұрын
After one day trying to understand Casting and finally just 5 minutes explained very clearly to be ok ! thanks !!!
@BillBarnum
@BillBarnum 4 жыл бұрын
Thanks for the feedback Amine. I'm glad you like the video.
@CindyMcGuirk
@CindyMcGuirk 6 жыл бұрын
Exactly what I needed to know at this moment. Thanks, Bill!
@HungryBirdStephenHaokip
@HungryBirdStephenHaokip 5 жыл бұрын
Thank you bill been stuck here for a long time now... downcasting is clear
@_mantis
@_mantis 4 жыл бұрын
I am really thankful for this tutorial. Keep up the good work!
@BillBarnum
@BillBarnum 4 жыл бұрын
Thanks for the feedback! I'm glad that you found it useful.
@zackaoz1034
@zackaoz1034 5 жыл бұрын
I love you Bill, finally a full tutorial with all possible examples.
@hiteshchalise3988
@hiteshchalise3988 6 жыл бұрын
really informative, and perfect explanation, thanks bill.
@HighOctaneNews570
@HighOctaneNews570 2 жыл бұрын
Finally someone who explains correctly this topic. Thank you Sir.
@BillBarnum
@BillBarnum 2 жыл бұрын
Thanks for watching and commenting, Alejandro.
@prabhatdahal3416
@prabhatdahal3416 4 жыл бұрын
Really helpful video man💯💯💯. keep uploading more videos . Thank you so much Bill ❤❤
@abdulaziz_xi
@abdulaziz_xi 4 жыл бұрын
Thanks man … Great explanation
@Astrovic1
@Astrovic1 3 жыл бұрын
it is midnight and will be writing an important exam at 8am :D after this video i finally got the object casting thank you haha :D
@BillBarnum
@BillBarnum 3 жыл бұрын
Good luck on your exam!
@robertastutlys8641
@robertastutlys8641 4 жыл бұрын
Exactly what i needed. Thanks for this great content!
@abdur1996
@abdur1996 3 жыл бұрын
Was looking for C# but this was very relavent regardless. I really really like the stack and heap insights in the tutorial as it helps understand whats *really* going on
@BillBarnum
@BillBarnum 3 жыл бұрын
Thanks for the feedback!
@SoftwareTestSolutions
@SoftwareTestSolutions 3 жыл бұрын
That is a great explanation... Thanks for the video!
@obit6380
@obit6380 3 жыл бұрын
Thanks for the video! Very clear and to the point presentation!
@BillBarnum
@BillBarnum 3 жыл бұрын
Thanks for the feedback, OBIT.
@anastasijad4830
@anastasijad4830 3 жыл бұрын
Thank you sir! God bless you
@ayoubanbara1685
@ayoubanbara1685 5 жыл бұрын
thanks you from morocco
@rho8931
@rho8931 2 жыл бұрын
Thank you so much for this awesome tutorial!
@BillBarnum
@BillBarnum 2 жыл бұрын
Glad it was helpful, Rhoad!
@criquetteable
@criquetteable 6 жыл бұрын
really good! perfect explanation thanks a lot
@joaovalerio8137
@joaovalerio8137 2 жыл бұрын
Brilliant explanation!
@BillBarnum
@BillBarnum 2 жыл бұрын
Thanks for watching and commenting, João!
@louishou781
@louishou781 6 жыл бұрын
this video is awesome - thank you so much
@نفرال-فيرزاتشي
@نفرال-فيرزاتشي 6 жыл бұрын
you're the best, keep it up
@s2k_love492
@s2k_love492 5 жыл бұрын
Excellent, helped a lot. Thank you!
@serhatgundem
@serhatgundem 3 жыл бұрын
Thanks a looooooot. You are great.
@BillBarnum
@BillBarnum 3 жыл бұрын
Thanks for the feedback Serhat. I'm had you liked the video!
@18DZ
@18DZ 3 жыл бұрын
Exactly what I needed before my exam!
@NikitaSafronov-y6i
@NikitaSafronov-y6i 2 жыл бұрын
OMGGGG!!! You are a genius!!! It's awesome =)
@BillBarnum
@BillBarnum 2 жыл бұрын
Thanks for watching and commenting!
@kbuvanesh5347
@kbuvanesh5347 Жыл бұрын
Very good explaination sir love ❤️ from India 🇮🇳
@rajdhar1235
@rajdhar1235 Жыл бұрын
Amazing explanation. Thank you.
@ИльяХимченко-н2и
@ИльяХимченко-н2и 5 жыл бұрын
Thanks a lot!
@AyumiNoran
@AyumiNoran 4 жыл бұрын
Thank you!
@BillBarnum
@BillBarnum 4 жыл бұрын
Thanks for the feedback. I'm glad you found it helpful.
@zhenyuanhe6071
@zhenyuanhe6071 4 жыл бұрын
Thanks a lot! Clear enough:)
@funnybunny3188
@funnybunny3188 2 жыл бұрын
Very good explanation i got my points
@BillBarnum
@BillBarnum 2 жыл бұрын
Thanks for watching and commenting.
@rafaybbx
@rafaybbx 2 жыл бұрын
amazing explanation
@BillBarnum
@BillBarnum 2 жыл бұрын
Glad you liked it
@johncerpa3782
@johncerpa3782 5 жыл бұрын
Great video
@camnooten110
@camnooten110 4 жыл бұрын
Thank you, this really helps
@IluSsIoNnN
@IluSsIoNnN 3 жыл бұрын
Thank you my good sir !!!!
@BillBarnum
@BillBarnum 3 жыл бұрын
Thanks for the comment, IluSsIoNnN.
@NikitaSafronov-y6i
@NikitaSafronov-y6i 2 жыл бұрын
01:10 does not Lion class inherit controlTemp() as well? If we talk about general inheritance as it is. So, in total Lion method has access to next method (via inheritance) eat() - from Animal sleep() - from Animal controlTemp() - from mammal and one own unique method roar() ear() @overridden
@jackwesh2976
@jackwesh2976 4 жыл бұрын
Loved it Thanks Much
@BillBarnum
@BillBarnum 4 жыл бұрын
Thanks for the feedback!
@langstonhodges5863
@langstonhodges5863 4 жыл бұрын
Do these same concepts hold true with the fields for the classes when upcasting and downcasting? This video only covers the interactions with methods.
@BillBarnum
@BillBarnum 4 жыл бұрын
Yes, it would work the same way with fields.
@langstonhodges5863
@langstonhodges5863 4 жыл бұрын
Bill Barnum Thank you very much it all makes since now.
@yalakaturi.saidivya9158
@yalakaturi.saidivya9158 2 жыл бұрын
Mutilple times of casting,by using single object is possible or not?
@BillBarnum
@BillBarnum 2 жыл бұрын
Yes. When you cast an object, you aren't changing any data. You are just "making promises" to the compiler that it is pointing at an object of the type you are casting it as.
@younesred112
@younesred112 4 жыл бұрын
Thank you so much !! awesome explanition
@lazry1773
@lazry1773 2 жыл бұрын
great video
@BillBarnum
@BillBarnum 2 жыл бұрын
Thanks for watching and commenting, Lazry!
@ginopaolettigeuna1946
@ginopaolettigeuna1946 3 жыл бұрын
excellent!
@BillBarnum
@BillBarnum 3 жыл бұрын
Thanks for the feedback Gino.
@real_hello_kitty
@real_hello_kitty 4 жыл бұрын
Thanks.👍
@kakashi99908
@kakashi99908 3 жыл бұрын
So what are the limitations of doing: Lion jen = new Lion()?
@BillBarnum
@BillBarnum 3 жыл бұрын
I recommend my video on Polymorphism. I think it will answer your question: kzbin.info/www/bejne/mYbLZIRvoZiEY5I
@kakashi99908
@kakashi99908 3 жыл бұрын
​@@BillBarnum I watched it but am still a little confused. In the classes Lion extends mammal, mammal extends animal so wouldn't Lion jen = new Lion() work without having to type cast any methods? Basically I am confused when you use Animal jen in place of Lion jen because they seem to do the same thing.
@BillBarnum
@BillBarnum 3 жыл бұрын
​@@kakashi99908 Let's take two variables: Animal alex = new Lion(); Lion jen = new Lion(); The methods available to alex are only those that are declared in Animal. So we could do alex.eat() and alex.sleep(), but we couldn't do alex.roar(), because the alex variable is an Animal and there is no roar() in the Animal class. On the other hand, the jen variable is declared as a Lion. Lion classes have the roar() method, so we COULD do jen.roar() The variable type determines what methods are available. The object type determines what version of the method is run.
@ramzirebai3661
@ramzirebai3661 2 жыл бұрын
Thank you so much
@BillBarnum
@BillBarnum 2 жыл бұрын
Thanks for watching and commenting Ramzi!
@jamesbakis6330
@jamesbakis6330 4 ай бұрын
What a fucking amazing description lol
@wasimpatel2618
@wasimpatel2618 2 жыл бұрын
i cant hear the sentence at 4:02. can anybody tell me pls.
@BillBarnum
@BillBarnum 2 жыл бұрын
"This is legal because we are assuring the compiler that Jen is, in fact, pointing at a Lion type object. "
@wasimpatel2618
@wasimpatel2618 2 жыл бұрын
@@BillBarnum thank you so much sir for explaining, I misheard is, in fact to "isn't fact ".
@spencerrobles9373
@spencerrobles9373 Жыл бұрын
Good video
@jangul8230
@jangul8230 5 жыл бұрын
v.good sir
@sweeren3619
@sweeren3619 5 жыл бұрын
ty so much
@moses.muchemi
@moses.muchemi 4 жыл бұрын
Lifesaver
@asitkumarsahu5211
@asitkumarsahu5211 3 жыл бұрын
How to cast string to user defined object type
@BillBarnum
@BillBarnum 3 жыл бұрын
Here are a couple of examples: Object x = new String("test 123"); //upcasting example String y = (String)x; //downcasting example
@ash2521
@ash2521 2 жыл бұрын
very descriptive
@BillBarnum
@BillBarnum 2 жыл бұрын
Thanks for watching and the comment, Aashish!
@Aloksheoran
@Aloksheoran 3 жыл бұрын
Good for mugging up only
@simongadd8545
@simongadd8545 3 жыл бұрын
Explained an hour of university lecture content in just under 6 minutes and so much better. Maybe I should pay you instead?
@BillBarnum
@BillBarnum 3 жыл бұрын
Thanks for the comment, Simon. I'm glad you thought it was a useful video!
@Subhash_VCU
@Subhash_VCU Жыл бұрын
Animal jen = new lion() Jen. Controltemp() , a valid statement??
@jsonwann8908
@jsonwann8908 4 жыл бұрын
thanks...
@maharun0
@maharun0 2 жыл бұрын
I have a serious confusion. Here it is: Animal
@BillBarnum
@BillBarnum 2 жыл бұрын
You can't override the sleep() function in the Animal class because that's where it originates. You can override sleep in a subclass that would otherwise inherit sleep() Does that answer your question?
@adriansalabanzi2250
@adriansalabanzi2250 6 жыл бұрын
cool.
@adityakuricheti6653
@adityakuricheti6653 2 жыл бұрын
lion l = new lion(); This is valid So will it come under downcasting?
@BillBarnum
@BillBarnum 2 жыл бұрын
Good question. In that case, the variable and object type are the same, so it isn't casting.
@adityakuricheti6653
@adityakuricheti6653 2 жыл бұрын
@@BillBarnum ok thanks
@khorLDW
@khorLDW 4 жыл бұрын
poor joe
@BillBarnum
@BillBarnum 4 жыл бұрын
That's what happens when you don't follow the rules of Java. 🙂
@xrealmob_1037
@xrealmob_1037 4 жыл бұрын
tx G
@barshabhattacharjee6788
@barshabhattacharjee6788 4 жыл бұрын
For more visit: kzbin.info/www/bejne/rZPViKOqYpKWndk
@NikitaSafronov-y6i
@NikitaSafronov-y6i 2 жыл бұрын
+
@mehmetali627
@mehmetali627 2 жыл бұрын
Good job bro
@BillBarnum
@BillBarnum 2 жыл бұрын
Thanks
@mehmetali627
@mehmetali627 2 жыл бұрын
@@BillBarnum you are welcome sir. You've saved my life in college.
@nodararonia1554
@nodararonia1554 5 жыл бұрын
Thank you!!
@Xtcent
@Xtcent 3 жыл бұрын
Great video
@BillBarnum
@BillBarnum 3 жыл бұрын
Thanks for checking out the video!
@Carlitos_SH
@Carlitos_SH 3 жыл бұрын
THANK YOU !
@anantshukla6395
@anantshukla6395 2 жыл бұрын
Awesome video
@BillBarnum
@BillBarnum 2 жыл бұрын
Thanks for watching and commenting, Anant!
@mahaaftab755
@mahaaftab755 2 жыл бұрын
great. thanks!
@BillBarnum
@BillBarnum 2 жыл бұрын
Thanks for commenting, Maha!
Upcasting and Downcasting in Java - Full Tutorial
10:22
Coding with John
Рет қаралды 189 М.
Polymorphism (Java Tutorial)
4:55
Bill Barnum
Рет қаралды 11 М.
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 17 МЛН
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 62 МЛН
The Flaws of Inheritance
10:01
CodeAesthetic
Рет қаралды 1 МЛН
Java Method References - A Beginner's Guide
12:59
Dan Vega
Рет қаралды 9 М.
Checking Equality in Java ( == vs equals method )
12:32
Bill Barnum
Рет қаралды 8 М.
Up-casting and Down-casting objects in Java (Inheritance)
10:44
NeoTech Academy
Рет қаралды 6 М.
.equals() vs. == in Java - The Real Difference
8:48
Coding with John
Рет қаралды 201 М.
Naming Things in Code
7:25
CodeAesthetic
Рет қаралды 2,3 МЛН
Primitive and Reference (Object) Types in Memory (Java Tutorial)
5:12
Fundamental Concepts of Object Oriented Programming
9:16
Computer Science Lessons
Рет қаралды 995 М.
Functions vs Classes: When to Use Which and Why?
10:49
ArjanCodes
Рет қаралды 176 М.
#59 Upcasting and Downcasting in Java
6:37
Telusko
Рет қаралды 129 М.
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 17 МЛН