我正在重构一个正在变大的android项目.运行lint为我提供了JSME问题 外部和内部类之间的私有成员访问.考虑以下示例
public class Outer { private Inner mInner = new Inner(); private class Inner {} }
我得到了这些信息
Name
private field Inner mInner
Location
class Outer (default package)
Problem synopsis
Access to private member of class 'Inner' at line 2
Problem resolution
Make 'Inner' constructor package-local
应用问题解决方案会将源更改为
public class Outer { private Inner mInner = new Inner(); private class Inner { Inner() {} } }
我此刻有点困惑.到现在为止,我认为这个例子相当于
public class Outer { private Inner mInner = new Inner(); private class Inner { public Inner() {} } }
在这种情况下我错了还是皮棉问题?