aspose file tools
The moose likes Beginning Java and the fly likes final & static Constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "final & static Constructor" Watch "final & static Constructor" New topic
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
    
    4
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
    
    2
And if they were allowed, what effect(s) would you expect them to have?
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: final & static Constructor
 
Similar Threads
contructor
final static variable
Constructord
inheritence and the use of private & protected memebrs
finalizing variables and setting the variables