| Author |
final & static Constructor
|
Anoop Nair
Ranch Hand
Joined: Oct 29, 2008
Posts: 66
|
|
|
Why cant the final and static modifiers be used with a constructor???
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32611
|
|
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
Joined: Jul 11, 2001
Posts: 14112
|
|
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?
|
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
|
 |
Mike Simmons
Ranch Hand
Joined: Mar 05, 2008
Posts: 2770
|
|
|
And if they were allowed, what effect(s) would you expect them to have?
|
 |
 |
|
|
subject: final & static Constructor
|
|
|