Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Protected Constructed

 
abin joy
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does a protected constructor for a class mean?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic