What's up with protected access in JAVA?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: What's up with protected access in JAVA?

  1. #1
    Join Date
    Dec 2003
    Posts
    38

    What's up with protected access in JAVA?

    Can anybody explain to me why the protected access specifier allows all classes within a package to access the protected member variable instead of only allowing derived classes to access the protected member variable like in C++.

    Thanks a million,

    -V

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    The use of a package means that there is a relationship among the classes in the package. They are designed to work together, support each other, provide service to each other.

    It can be seen as providing "friend" functionality to Java.

    If you don't want to give classes this kind of access, make the method/field private, or don't create a package.

Similar Threads

  1. DevX does seem one sideded
    By Rob Abbe in forum Talk to the Editors
    Replies: 44
    Last Post: 01-13-2003, 03:57 PM
  2. how to access password protected database?
    By Sean in forum VB Classic
    Replies: 6
    Last Post: 07-23-2002, 09:04 PM
  3. Access 97 to 2000 Conversion Error
    By Michelle in forum VB Classic
    Replies: 8
    Last Post: 04-19-2002, 06:01 PM
  4. Replies: 0
    Last Post: 12-25-2000, 08:45 AM
  5. Replies: 0
    Last Post: 06-16-2000, 03:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center