Ol�.Entendi pelo trecho abaixo do The Java
Tutorial, que construtores n�o podem ser herdados:
What Members Does a Subclass Inherit?
O trecho a seguir faz parte
do cap�tulo 6 do livro Thinking in Jana, 2nd edition, Revision 12 de
Bruce Eckel, mostrando que os construtores s�o herdados das classes bases, at�
mesmo se vc n�o criar um (ver �ltima linha do trecho):
Java
automatically inserts calls to the base-class constructor in the derived-class
constructor. The following example shows this working with three levels of
inheritance:
The output for this program shows the automatic
calls: Art constructor Drawing constructor Cartoon constructor You can see that the construction happens from the base
�outward,� so the base class is initialized before the derived-class
constructors can access it. [ Add Comment ] Even if you don�t create a constructor for Cartoon( ), the compiler will synthesize a default constructor for you that calls the base class constructor. [ Add Comment ]
O que entendi errado? � interessante colocar os membros da super classe a ser herdada nos construtores ou � melhor evitar? Por qu�? Obrigado, Airton |
- Re: [java-list] Heran�a de construtores Airton
- Re: [java-list] Heran�a de construtores Marcelo Quintella
- Re: [java-list] Heran�a de construtores Sven van �t Veer
