1/22/2024 0 Comments Java interface member variables![]() ![]() So before you go on complaining about private variables can be accessed from other classes, show us your concrete example and we can tell you why it may be the case or if its not the case at I think you misunderstood the question. It's meant to communicate a clear seperation between private / internal concerns and the public available interface that a class provides. Keep in mind that the access level / access modifiers in programming languages are not meant as security measures, but as a protection against the programmers own stupidity. It's its own ecosystem on top of the normal type / class system. Though reflection does not simply gives direct access to those fields. They often use reflection to get access to private fields. Some systems (the best examples are serialization systems) do require access to private / internal fields in order to actually save and restore an instance. ![]() This is more like a stored away general key for emergencies. With reflection you can bypass any private protection, but that's intentional and should only be used when its absolutely necessary. ![]() So when you have everything inside the Unity project, internal just means the same as public. However to the outside of that module internal fields, methods, types are essentially private Of course in Unity usually all your scripts are compiled to the same module unless you use assembly definition files or when you manually compiled and use your own DLLs. Internal is a special keyword that treats all members as public when accessed from the same module / DLL / EXE. The second exception is the use of the internal keyword on types.So the scope bubbles outwards but never inwards. However other apartments (other nested classes) you can not access. So when you leave your apartment, you actually enter the house and can reach everything in that house. You essentially are in an apartment (the nested class) that is located inside a large house. Your apartment analogy does completely make sense here. The outer class can not access private members of the inner / nested class. So the nested class can access private variables and methods of the outer class. Even though they are technically two separate classes, the nested class is within the scope of the outer class. First having a nested class, those two classes are somewhat related.There are only a few exceptions and maybe you hit one of them. Click to expand.You've going on for 3 posts now stating that another external class can access private members of another external class but you still have not shown any example. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |