Replace while loop with for each : <p>How can I replace while loop below with for each loop in Java? </p>

<pre><code>JSONObject postParameters = new JSONObject();
Map parameterMap = httpRequest.getParameterMap();
Iterator&lt;Map.Entry&lt;String, String[]&gt;&gt; it = parameterMap.entrySet().iterator();
while (it.hasNext()) {
    Map.Entry&lt;String, String[]&gt; entry = it.next();
    if(entry.getValue().length == 1){
        postParameters.put(entry.getKey(), entry.getValue()[0].toString());
    }
    else{
        JSONArray valueList = new JSONArray();
        for(String value : entry.getValue()){
            valueList.add(value.toString());
        }
        postParameters.put(entry.getKey(), valueList);
    }
}
</code></pre>

<p>Basically I want to make it bit more readable.</p>
