jQuery in Action, 2nd edition*
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: diff between protectec and none("package access")
 
Similar Threads
Problem with localization (MyFaces and JSTL)
protected Vs default access modifiers?
Top level classes
Error on K&B exercise in Chap 10...
Private variables and get/set