Why am I able to call private method?

后端 未结 8 1464
深忆病人
深忆病人 2020-12-10 21:29

I should not be able to invoke a private method of an instantiated object. I wonder why the code below works.

public class SimpleApp2 {
    /**
     * @param         


        
8条回答
  •  暖寄归人
    2020-12-10 21:44

    The call you issue is from within the same class where your private method resides. This is allowed. This is the way 'private' is defined in java.

提交回复
热议问题