No enclosing instance of type ObjectTest is accessible. Must qualify the allocation with an enclosin

编程入门 行业动态 更新时间:2024-10-28 04:27:51

No enclosing instance of <a href=https://www.elefans.com/category/jswz/34/1769883.html style=type ObjectTest is accessible. Must qualify the allocation with an enclosin"/>

No enclosing instance of type ObjectTest is accessible. Must qualify the allocation with an enclosin

刚刚写代码运行出错, 报的问题:

No enclosing instance of type ObjectTest is accessible. Must qualify the allocation with an enclosing instance of type ObjectTest (e.g. x.new A() where x is an instance of ObjectTest).

大概意思就是:无法访问ObjectTest类型的封闭实例。必须用ObjectTest(例如x)类型的封闭实例限定分配。new A()其中x是ObjectTest的实例)。                       

我要在mian方法里面调用自己写的内部类,出现了此问题。其实还是由于不仔细构成的,因为main方法是静态的,而自己写的内部类是动态的。只要在内部类前加上static就行。

问题出现在:

                                     

看代码:

package cn.liu.io3;import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputS

更多推荐

No enclosing instance of type ObjectTest is accessible. Must qualify the allocat

本文发布于:2024-02-07 06:23:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1754204.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:type   ObjectTest   enclosing   instance   allocation

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!