关于#java#的问题,如何解决?

显示Exception in thread "main" java.lang.Error: Unresolved compilation problem: The method Person() is undefined for the type Demo1
要求让我们把方法和运行分开写,但是出错了。

public class Person {
    System.out.print("我是李华");
}


public class Demo1 {

    public static void main(String[] args) {
        Person();

    }

}


img

System.out.print("我是李华");

这个语句你需要在方法体里面去写。比如


public class Person {
    public void print(){
         System.out.print("我是李华");
    }
}

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^