switch (from) {
case TAGs.casts://constant expression required
break;
}
//我的TAGs.casts是这样的
public interface TAGs {
String casts = String.class.getSimpleName();
}
//如果写成这个样子就可以编译
public interface TAGs {
String casts = "String";
}
不是说接口中的成员变量都是常量吗?为什么在case上使用不了提示需要常量呢?
使用接口要给常量赋初值,你自己写的没有给定初值,肯定是错的啊。