0
I can't understand dowen casting and upcasting
2 odpowiedzi
+ 2
Casting is changing type of variable.
There are 2 types of casting
1. Downcasting - cast from parent to child
e.g.
Object o = new String("a string");
String s = (String)o;
2. Upcasting - child to parent
e.g.
String s = new String("abc");
Object o = (Object)s;
Note that Object is parent of String.
0
good explanation