//Enum class
package model.cards;
public enum Rarity {
BASIC, COMMON, RARE, EPIC, LEGENDARY}
//Different class
package model.cards.minions;
import model.cards.Rarity;
public class Icehowl {
private int manaCost=9;
private Rarity rarity=LEGENDARY; //error "LEGENDARY" can not be resolved to a variable
private boolean attacked=true;
private int maxHP=10;
}
您的意思
private Rarity rarity = Rarity.LEGENDARY;
枚举值LEGENDARY
是类型Rarity
中的常数。