我试图在另一个类中使用枚举对象,但无法弄清楚我做错了什么。
这是我的第一个类中尝试引用第二个类的代码行。
Model model = new Model();
Model.Outcome outcome = new getgameOutcome(uChoice,cChoice);
这是我试图在“Model”类中引用的实际对象。
public enum Outcome{
WIN,LOSS,TIE
}
public Outcome getgameOutcome(String uChoice, String cChoice){
然后继续剩下的。
最佳答案
您没有创建新实例,只是分配方法的返回值。因此,您不需要 new
运算符:
Model.Outcome outcome = getgameOutcome(uChoice,cChoice);
关于java - 引用另一个类中的枚举对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30563160/