File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Difference between protected and default. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Difference between protected and default." Watch "Difference between protected and default." New topic
Author

Difference between protected and default.

merlin bar
Ranch Hand

Joined: Feb 16, 2003
Posts: 54
*Only classes within the same package can see a default class.
*Protected classes can only be seen within the same package(, or subclasses of the class).
I understand the first statement. But the second statement, the part in brackets seems redundant. If the scope is package wide, then does this not also include subclasses?
If so, this means there is no difference between default and package scope.
Any clarity is appreciated.
Regards,
merlin


Regards,<br /> merlin_bar
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34


If the scope is package wide, then does this not also include subclasses?

It does indeed include subclasses in the same package, but not those in other packages. "protected" extends access to all subclasses regardless of package location.


[Jess in Action][AskingGoodQuestions]
merlin bar
Ranch Hand

Joined: Feb 16, 2003
Posts: 54
Ah, I see. Subclasses in another package - I didn't think that was possible. Thankyou for the clarification.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between protected and default.