Accountant م :
My IDE says
Error: can only iterate over an array or an instance of java.lang.Iterable
On the headers.map()
in this code
import java.net.http.HttpHeaders;
import java.net.http.HttpRequest;
public static String dumpRequest(HttpRequest request)
{
HttpHeaders headers = request.headers();
for (Map.Entry<String, List<String>> header : headers.map()) {
}
}
However the documentation of the map()
in my IDE says it returns a Map<String, List<String>>
, what am I missing ? please consider I'm very new to JAVA
I'm using JAVA 14
This is the documentation of HttpHeaders that I'm using
Sean Patrick Floyd :
Close.
for (Map.Entry<String, List<String>> header : headers.map().entrySet())
Map itself does not extend the Iterable
interface, so it can't be iterated using foreach.
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=378527&siteId=1