• Post Reply Bookmark Topic Watch Topic
  • New Topic

Access Specifiers  RSS feed

 
Christy John
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I remember of reading this in one Java book.
If we don't specify any access specifiers the default one is called " friendly".
But when I told this to my instructor he said this is not correct. There is no friendly in Java. As I checked now I can't see friendly in any of te books, but one of my friends also claim to have read about the access specifier.
I would like any of the Java gurus in here to help me. Who is correct me or my instructor. Is there an access specifier termed friendly in Java?
Thank you.
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no friendly in Java.

If you don't specify an access modifier, then it has default access which means that only the current class and other classes in the same package can access it.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Christy John:
I remember of reading this in one Java book. If we don't specify any access specifiers the default one is called "friendly"...

There is no official term for Java's default access. As Keith explained, the default is to allow access from within the same package.

There are many unofficial terms for describing this, including "friendly," "package," "package default," "package friendly," "package private," etc. These terms might show up in different references, but the Java Language Specification carefully avoids using any such term in section 6.6.1 Determining Accessibility: "...we say there is default access, which is permitted only when the access occurs from within the package..."

Note: Bruce Eckel acknowledges the use of "friendly" in chapter 5 of Thinking in Java (3rd edition): "The default access has no keyword, but it is commonly referred to as package access (and sometimes 'friendly')."
[ March 27, 2007: Message edited by: marc weber ]
 
Christy John
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much. This slves my confusion.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!