Hi All,

I apologize if this question has been answered, but I've read all the
lessons and supporting material (up to "inner class," at least) and I've
spoken to a colleague who has taken a similar intro to Java class, but I
still can't figure this out.

My question is this:  I know that it's possible to do have a simple class
hierarchy like this:

Animal
-----Dog

And to create an object like this:

Animal dog1 = new Dog();

But I'm curious as to why you would do that when you can just write:

Dog dog1 = new Dog();

because it seems like either way the compiler would know that a Dog object
is a subclass of Animal, right?  Is it partially for code readability?

Can anyone give me an example of where you'd want to use one method over the
other, and what the benefits (e.g. performance) might be when using one
method over the other?


Thanks in advance!

Cheers,

-m

-- 
Love is a snowmobile racing across the tundra and then suddenly it flips
over, pinning you underneath. At night, the ice weasels come.

- Matt Groening

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to