Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Protected Access Specifier  RSS feed

 
kedar parundekar
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why "Protected" access specifier is not allowed to Top Level classes?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15859
80
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at it this way: Suppose you could make a top level class "protected". What would that mean? Why would that be useful?
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jesper Young:
Look at it this way: Suppose you could make a top level class "protected". What would that mean?


It would mean your code is protected for more secure programming, right?
 
Campbell Ritchie
Sheriff
Posts: 53720
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What would that mean?

I have never tried it, but I think it would mean that there is no access to subclasses outside the superclass' package. Anybody wish to try it? I don't.

CR
 
kedar parundekar
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jesper Young:
Look at it this way: Suppose you could make a top level class "protected". What would that mean? Why would that be useful?


I agree with you answer.
But my another query is -> If I want to use this protected class in same package only. why it is not useful?
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kedar parundekar:

If I want to use this protected class in same package only. why it is not useful?


In your hypothetical change to Java, what would be the difference between these two top-level classes?

[ May 17, 2006: Message edited by: Jeff Albertson ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!