Author Topic: [Java] Friend Scoping  (Read 16943 times)

0 Members and 1 Guest are viewing this topic.

Offline Networks

  • Full Member
  • ***
  • Posts: 415
  • I haven't visited my profile!
    • View Profile
[Java] Friend Scoping
« on: March 13, 2005, 12:57:40 pm »
What's the difference between scoping a variable or object as public and friend? You seem to have the same amount of access if the variable or object was public if you declared it to be friend and vise versa.

[16:50:11] Networks:0:32: What will soup bot be like?
[16:50:15] Warrior[x86]:16:-1: soup-like.
[16:50:21] warzofbeta@Lordaeron:0:62: Like god.
[16:50:26] Warrior[x86]:16:-1: Fake?

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: [Java] Friend Scoping
« Reply #1 on: March 13, 2005, 01:42:32 pm »
There are friends? I never knew that.

Ok, Networks clarified: I know these "friend" variables as "package protection".

The idea of package protection is that only classes within their package can access them.  Any class in a different package can't.  In public, anything (in or out of their package) is allowed to access them.

I don't recommend ever using package protection.
« Last Edit: March 13, 2005, 01:48:42 pm by iago »