Page 1 of 1

what this line does ??

Posted: Fri Feb 16, 2018 12:38 am
by maty.tsoraro@gmail.com
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:

Re: what this line does ??

Posted: Mon Feb 19, 2018 1:20 am
by dbremmen@gmail.com
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

Re: what this line does ??

Posted: Tue Feb 20, 2018 4:12 am
by maty.tsoraro@gmail.com
thank you !