In http://www.javapassion.com/javase/javainterface.pdf page 21 it says

Interfaces and classes are both types
– This means that an interface can be used in places
where a class can be used
– For example:
// Recommended practice               <<----
PersonInterface pi = new Person();  <<----
// Not recommended practice          <<----
Person pc = new Person();             <<----

Why would it be the recommended practice to type a new object by its interface name?

Tanya

--~--~---------~--~----~------------~-------~--~----~
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