It is not a good practice because you already have one variable in the
super class with the same name and for some people it might be
confusing when reading the code. They would not know which variable
you are talking about.

To make a difference between the variables you'd have to do this:
this.varName for the instance variable
super.varName for the super class variable


On May 23, 1:16 pm, ghanoz2480 <[email protected]> wrote:
> I read a tutorial about inheritance (http://java.sun.com/docs/books/
> tutorial/java/IandI/subclasses.html) and i want to ask why when we can
> declare a field in the subclass with the same name as the one in the
> superclass, it is not recommended?
> Anybody can help explained about it? Or have a "good resource" to
> share me about that question? Thank you.

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