News:

How did you even find this place?

Main Menu

[Java] Friend Scoping

Started by Networks, March 13, 2005, 12:57:40 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Networks

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.

http://www.zeroforce.net

Quote
[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?

iago

#1
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.