Take string and compare to multiple enum types all at once
This question already has an answer here:
您可以将输入转换为枚举
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/38096.html
上一篇: 如何从字符串值中获取ENUM
下一篇: 采取字符串并一次比较多个枚举类型