This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Protected Constructed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Protected Constructed" Watch "Protected Constructed" New topic
Author

Protected Constructed

abin joy
Ranch Hand

Joined: Jul 29, 2008
Posts: 35
What does a protected constructor for a class mean?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

It means that constructor cannot be used by a class outside that particular package (unless the calling class extends the class with the protected constructor).

Why you might use a protected constructor is harder to explain. One possible implementation could be in some sort of creation pattern where all the classes that participate in the pattern sit in one package and you don't want classes outside this calling the constructor directly.
[ September 02, 2008: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Protected Constructed
 
Similar Threads
WA #1.....word association
protected function
finalize
constructor
How come public and friendly(default) access is allowed for top level class but not