Accessing private inner class in the same package

前端 未结 2 1125
礼貌的吻别
礼貌的吻别 2021-02-20 07:12

I have two compilation units:

public class OuterClass{

    private static class InnerClass{

        public String test(){
            return \"testing123\";
           


        
2条回答
  •  轮回少年
    2021-02-20 07:34

    Private access modifier is stronger than package one (i.e. not having an access modifier at all in Java). Hence private elements of class - be it fields, methods or inner classes - are accessible only within that class.

提交回复
热议问题