• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

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: 65365
248
  • 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?
 
Master Rancher
Posts: 3313
31
  • 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?
 
Forget this weirdo. You guys wanna see something really neat? I just have to take off my shoe .... (hint: it's a tiny ad)
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!