I have a string:
"1, 2, 3 , -4"
它由", "分割。我有一个将数字转换为枚举类型的函数,它可以正常工作。我想使用Java 8将此字符串转换为枚举对象列表。
Pattern pattern = Pattern.compile(", ");
List<f> fList = pattern.splitAsStream(str)
.map(s -> {
try {
return this.getEnumObject(Integer.valueOf(s), f.class);
}
catch (NoEleException e) {
e.printStackTrace();
}
})
.collect(Collectors.toList());
这个给了我一个错误:
missing return type.
我该如何修复它?
catch
块中抛出new RuntimeException(e)
。 - Misha