包含< my reference>的封闭实例是必须的 [英] An enclosing instance that contains <my reference> is required

查看:59
本文介绍了包含< my reference>的封闭实例是必须的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

包含的封闭实例是必需的

An enclosing instance that contains is required

下面是代码. positionObj是我要使用的对象,它给了我上面的错误.

Below is the code. positionObj is the object that I am trying to use and it is giving me the above error.

不清楚为什么.

package toolBox;
import toolBox.Secretary.positionObj;    

public class PositionManagement {
    public static HashMap<String, Secretary.positionObj> main(String vArg){
        positionObj newPosition=new positionObj();
    }
}

推荐答案

您正在尝试使用不带Secretary实例的非静态内部内部positionObj类.
非静态内部类必须属于其父类的实例

You're trying to use the non-static inner positionObj class without an instance of Secretary for it to belong to.
A non-static inner class must belong to an instance of its parent class

您可能应该将positionObj更改为普通类或静态内部类.

You should probably change positionObj to a normal class or a static inner class.

或者,您可以编写someSecretary.new positionObj()来创建属于someSecretary实例的内部类的实例.

Alternatively, you can write someSecretary.new positionObj() to create an instance of the inner class that belongs to the someSecretary instance.

这篇关于包含&lt; my reference&gt;的封闭实例是必须的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆