Java – is the constructor of a private inner class also private?

I'm refactoring a growing Android project Running lint provides me with private member access between external and internal classes of JSME problems Consider the following example

public class Outer {
    private Inner mInner = new Inner();

    private class Inner {}
}

The information I got

Name
   privatefieldInnermInner

Location
   classOuter (default package)

Problem synopsis
   Access to private member of class 'Inner' at line 2

Problem resolution
   Make 'Inner' constructor package-local

Applying a problem solution changes the source to

public class Outer {
    private Inner mInner = new Inner();

    private class Inner {
        Inner() {}
    }
}

I'm a little confused at the moment So far, I think this example is equivalent to

public class Outer {
    private Inner mInner = new Inner();

    private class Inner {
        public Inner() {}
    }
}

In this case, am I wrong or lint problem?

Solution

Section 8.8. 9 of the Java language specification, "default constructor" says:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>