This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Constructor Modifiers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Constructor Modifiers" Watch "Constructor Modifiers" New topic

Constructor Modifiers

Jimmy Blakely
Ranch Hand

Joined: Jul 10, 2001
Posts: 57
Aside from accessibility modifiers, do constructors accept any other types of modifiers?

I'm currently testing the hypothesis that constructors can only be preceded by accessibility modifiers (public, private, protected, default). Is this true?
Carl Trusiak

Joined: Jun 13, 2000
Posts: 3340
If you put a return type, java considers it to be a method and it will not create that constructor. Modifiers such a synchronized, native ext. wll throw a compile time exception.

I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Jimmy Blakely
Ranch Hand

Joined: Jul 10, 2001
Posts: 57
Never mind.
I just finished testing it out.
Constructors cannot accept static, final, abstract, synchronized, or native as modifiers.
Naturally, the same is true for transient and volatile since they are only used to modify variables and not methods.
I agree. Here's the link:
subject: Constructor Modifiers
It's not a secret anymore!