what this line does ??

Do you have a compilation error or a difficult problem to solve? Ask for help here
Post Reply
maty.tsoraro@gmail.com
Posts: 32
Joined: Thu Dec 21, 2017 10:06 pm

what this line does ??

Post by maty.tsoraro@gmail.com » Fri Feb 16, 2018 12:38 am

http://www.beta.browxy.com#USER_155663

hi,(above the URL Link)
can you please explain these lines :
C cd = new D();//cd is object of C.and is now an object in D also ??
D dd = (D) cd; // no idea at all !!? :oops:

dbremmen@gmail.com
Posts: 63
Joined: Sun Jan 07, 2018 6:30 pm

Re: what this line does ??

Post by dbremmen@gmail.com » Mon Feb 19, 2018 1:20 am

Hi!
This operation is called casting.
Casting really means is taking an Object of one particular type and “turning it into” another Object type
For more information there are plenty information on inet, for instance: https://howtoprogramwithjava.com/java-cast/
In your particular case in the 2nd line you are casting the object cd to the type D

maty.tsoraro@gmail.com
Posts: 32
Joined: Thu Dec 21, 2017 10:06 pm

Re: what this line does ??

Post by maty.tsoraro@gmail.com » Tue Feb 20, 2018 4:12 am

thank you !

Post Reply