【发布时间】:2020-12-05 21:43:39
【问题描述】:
这里有什么问题?
class UserInput {
public void name() {
System.out.println("This is a test.");
}
}
public class MyClass {
UserInput input = new UserInput();
input.name();
}
这抱怨:
<identifier> expected
input.name();
【问题讨论】:
-
你缺少构造函数吗?
-
你不能把
input.name();放在任何你想要的地方,它必须在一个方法里面。 -
这也可以通过缺少匹配的花括号来表现出来......特别是如果它也抱怨枚举。
标签: java