枚举的使用:
public class Test{
private enum Methods{
index;
/**
* 里面是否包含此字符串
*
* @param string
* @return
*/
public static boolean isIn(String string) {
try {
Methods.valueOf(string);
return true;
} catch (Exception e) {
return false;
}
}
}
if(!"".equals("index") && Methods.isIn("index")){
switch(Methods.valueOf("index")&&){
case index:
.......
break;
}
}
}
上面是属于行(inline)声明Enum,而嵌套的enum隐含着static,所以这里加不加static都一样,就像声明一个interface为abstract的一样是多余的