aspose file tools*
The moose likes Beginning Java and the fly likes diff between protectec and none( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "diff between protectec and none("package access")" Watch "diff between protectec and none("package access")" New topic
Author

diff between protectec and none("package access")

sunitha reghu
Ranch Hand

Joined: Dec 12, 2002
Posts: 937
If i write class Employee {
String name;
}, means it is accessible within the package rt.
so wat is the difference if i write protected String name
class Employee{
protected String name;}
both means members are accessible inside the package rt?
Blake Minghelli
Ranch Hand

Joined: Sep 13, 2002
Posts: 331
Yes, both are accessible in your package, BUT protected also gives subclasses of Employee access to it.
If you don't specify the access modifier, then it is considered "default" access and subclasses can't access it.


Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
sunitha reghu
Ranch Hand

Joined: Dec 12, 2002
Posts: 937
Thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: diff between protectec and none("package access")