我想将字符串转换为枚举。但是怎么做?
class Letter {
A, B, C
}
String letter = "A";
switch (letter) {
case Letter.A: //cannot convert from Letter to String
case Letter.A.toString(): //case expressions must be constant expressions
case Letter.C.name(): //case expressions must be constant expressions
default:
}