• Post Reply Bookmark Topic Watch Topic
  • New Topic

Overwriting Constructors  RSS feed

 
Wolfgang Obi
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is ist possible to overwrite a constructor?

-W.O.
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean override?

No it is not.

Constructors aren't inherited.
 
Wolfgang Obi
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no i meant overwriting.

...thanks!
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not familiar with that term.

Do you mean overloading?
 
Wolfgang Obi
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keith,

you were right it's Override!
just researched.

my mistake was translating directly from German to English....
�berschreiben (Override) = Overwrite (literal translation).

thanks for the help anyway.

-W.O.
 
Suhita Reddy
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No,we can't override a constructor
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A constructer is meant only for that particular class.

You can overload it but cann't be overrided



 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I buy the argument that since it doesn't have the same name and it ain't inherited a constructor can't be overridden. I couldn't find "overriding constructor" in the JLS either.

But a quick Google shows that quite a few articles and books and such call it "overriding a constructor" even though the class name in the signature is different. Since a constructor isn't a method I wonder if it might be ok to call this a special case of overriding:

I'm not sure what else I'd call it. Got a better name?
[ July 10, 2006: Message edited by: Stan James ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!