JAVA出现“Exception in thread “main” java.lang.Error: Unresolved compilation problem: ”异常处理
代码报错
Exception in thread “main” java.lang.Error: Unresolved compilation problem:
No enclosing instance of type PersonTest is accessible. Must qualify the allocation with an enclosing instance of type PersonTest (e.g. x.new A() where x is an instance of PersonTest).
at com.atguigu.java.PersonTest.main(PersonTest.java:6)
在学习面向对象这一章时,执行以下代码报出来了上述错误,通过查阅资料发现是在java类中,静态方法不能调用动态类,因此,我将类调整为静态,之后就不报错了
package com.atguigu.java;
public class PersonTest {
public static void main(String[] args) {
Person p1 =new Person();
p1