java - Do objects encapsulate data so that not even other instances of the same class can access the data? -


In Java,

Objects explain the data so that access to other instances of the same class Ho statistics? Only when the word "private" is used? What are the "accessory ways" in Java - like Millenam ()?

Thanks

I call it item , But which of the data is access to an object code in an object.

Within a class Java (and C #, BTW) code can access private members of any object in the same class. Then you have got package / assembly access and public access.

Hardly have a secure access, which has access to the code in the type of subclasses - but it depends on the object object: to reach only the protected members of the object It is allowed if it is an example of the location of the code, or the same type of some subclass - even if it is emerged by a parent class. For example, suppose you had:

  class guardian {protected intestine x; } Class child increases the parents' 1 Child2 extended basic class increases the babysitter child 1  

Then within the Child1 code, you Parent.x Examples of only those items that are known (at code-time) are Child1 or grandchild . For example, you can new parent (). X or new child2 (). X .


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -