我创建了这个类:
public class Ena {
public void displayMessage(String name)
{
System.out.println("Your name is: " + name);
}
}
我希望在另一个使用main方法的地方使用它:
import java.util.*;
public class Duo {
public static void main(String[] args)
{
Scanner key = new Scanner(System.in);
Ena onoma = new Ena();
System.out.println("Enter your name: ");
String yourName = key.nextLine();
onoma.displayMessage(yourName);
}
}
显示错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Ena cannot be resolved to a type
Ena cannot be resolved to a type
at Duo.main(Duo.java:9)
为什么?