Я хочу, чтобы реструктурировать ниже кодКак изменить структуру моего вывода, эффективно используя итератор или любую другую вещь?
Map m=request.getParameterMap();
Set s = m.entrySet();
Iterator it = s.iterator();
out.print("<h1> Your Input Based on MapParamters</h1><br><br>");
while(it.hasNext()){
Map.Entry<String,String[]> entry = (Map.Entry<String,String[]>)it.next();
String key = entry.getKey();
String[] value = entry.getValue();
out.println(key + " : ");
if(value.length>1){
for (int i = 0; i < value.length; i++) {
out.println("<li>" + value[i].toString() + "</li>");
}
}else
out.println(value[0].toString()+"<br><br>");
}
выход как
ISBN :
-1
-2
-3
-4
Title :
-5
-6
-7
-8
Price :
-9
-10
-11
-12
But I want the output like
ISBN : 1
Title : 5
Price : 9
ISBN : 2
Title : 6
Price : 10
ISBN : 3
Title : 7
Price : 11
ISBN : 4
Title : 8
Price : 12