Access private field of a instance object

后端 未结 5 1047
孤城傲影
孤城傲影 2021-01-13 22:38

I have a class, which has one field named orbits (it has the same type as my class Body and has the private modifier):



        
5条回答
  •  温柔的废话
    2021-01-13 23:01

    Privacy is not per instance - it's per class.

    The class can access the private fields of all instances.

    For example, the method equals( Object o ) can cast o (if appropriate) to the same type, and compare its private members with the object on which equals() was called.

提交回复
热议问题