显示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();
}
}
System.out.print("我是李华");
这个语句你需要在方法体里面去写。比如
public class Person {
public void print(){
System.out.print("我是李华");
}
}
不知道你这个问题是否已经解决, 如果还没有解决的话: