Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ObjectCastingEx {
- Animal ani = new Dog(); //implicit casting
- Dog dg1 = new Animal()//compile-error
- Dog dg2 = (Dog)ani;//explicit casting
- }
- class Animal {
- }
- class Dog extends Animal{
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement