采取字符串并一次比较多个枚举类型
这个问题在这里已经有了答案:
您可以将输入转换为枚举
System.out.print("Please enter your photo's file type. It must be: JPG, GIF, PNG, BMP, or OTHER");
boolean typeInput = kb.nextLine();
inputMatches = true;
try{
FileType fileType = FileType.valueOf(inputString.toUpperCase().trim());
}catch (IllegalArgumentException e) {
inputMatches = false;
}
链接地址: http://www.djcxy.com/p/38095.html
上一篇: Take string and compare to multiple enum types all at once