This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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
Error on K&B exercise in Chap 10...
protected Vs default access modifiers?
Top level classes
Problem with localization (MyFaces and JSTL)
Private variables and get/set