我呈现结果的代码如下:
private void presentResult(List<Long> result) {
if(result.size() == 0) {
System.out.println("No matching values for the provided query.");
}
for(String s : result) {
System.out.println(s);
}
}
但是我想返回一个哈希表而不是列表,所以我希望它像这样:
private void presentResult(Map<LocalDate, Long> result) {
if(result.size() == 0) {
System.out.println("No matching values for the provided query.");
}
for(Map<LocalDate, Long> s : result) {
System.out.println(s);
}
}
但随后出现此错误:“只能迭代数组或java.lang.Iterable的实例”如何解决?