• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

final & static Constructor

 
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???
 
Marshal
Posts: 70224
282
  • 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
 
author
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?
 
Rancher
Posts: 3625
40
  • 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?
 
    Bookmark Topic Watch Topic
  • New Topic