• Post Reply Bookmark Topic Watch Topic
  • New Topic

final & static Constructor  RSS feed

 
Anoop Nair
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why cant the final and static modifiers be used with a constructor???
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch

That looks like a beginner's question.

A constructor is reconstructed every time you extend a class, so it has to be different for each class and final would be meaningless.
It creates an object, so calling it static would be a bit silly.

In that case, the designers of Java decided to prohibit calling constructors final or static. You only want modifiers when they actually do something.

Hope I haven't made it harder to understand.

CR
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by naruto uzumaki:
Why cant the final and static modifiers be used with a constructor???


Well, why should it be allowed to do so?
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And if they were allowed, what effect(s) would you expect them to have?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!